.NET Standard DateTime Format Strings
.NET Standard DateTime Format Strings | ||
---|---|---|
Specifier | Name | Description |
d | Short date pattern | Represents a custom DateTime format string defined by the current ShortDatePattern property. |
D | Long date pattern | Represents a custom DateTime format string defined by the current LongDatePattern property. |
f | Full date/time pattern (short time) | Represents a combination of the long date (D) and short time (t) patterns, separated by a space. |
F | Full date/time pattern (long time) | Represents a custom DateTime format string defined by the current FullDateTimePattern property. |
g | General date/time pattern (short time) | Represents a combination of the short date (d) and short time (t) patterns, separated by a space. |
G | General date/time pattern (long time) | Represents a combination of the short date (d) and long time (T) patterns, separated by a space. |
M or m | Month day pattern | Represents a custom DateTime format string defined by the current MonthDayPattern property. |
o | Round-trip date/time pattern | Represents a custom DateTime format string using a pattern that preserves time zone information. The pattern is designed to round-trip DateTime formats, including the Kind property, in text. Then the formatted string can be parsed back using Parse or ParseExact with the correct Kind property value. Equivalent custom format string is "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK". |
R or r | RFC1123 pattern | Represents a custom DateTime format string defined by the current RFC1123Pattern property. The pattern is a defined standard and the property is readonly. Equivalent custom format string is "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'". Does not convert DateTimes to UTC. |
s | Sortable date/time pattern; ISO 8601 | Represents a custom DateTime format string defined by the current SortableDateTimePattern property. This pattern is a defined standard and the property is read-only. Equivalent custom format string is "yyyy'-'MM'-'dd'T'HH':'mm':'ss". |
t | Short time pattern | Represents a custom DateTime format string defined by the current ShortTimePattern property. For example, the custom format string for the invariant culture is "HH:mm". |
T | Long time pattern | Represents a custom DateTime format string defined by the current LongTimePattern property. For example, the custom format string for the invariant culture is "HH:mm:ss". |
u | Universal sortable date/time pattern | Represents a custom DateTime format string defined by the current UniversalSortableDateTimePattern property. Equivalent custom format string is "yyyy'-'MM'-'dd HH':'mm':'ss'Z'". Does not convert DateTimes to UTC. |
U | Universal sortable date/time pattern | Represents a custom DateTime format string defined by the current FullDateTimePattern property. This pattern is the same as the full date/long time (F) pattern. However, formatting operates on the Coordinated Universal Time (UTC) that is equivalent to the DateTime object being formatted. |
Y or y | Year month pattern | Represents a custom DateTime format string defined by the current YearMonthPattern property. For example, the custom format string for the invariant culture is "yyyy MMMM". |
Any other single character | (Unknown specifier) | An unknown specifier throws a runtime format exception. |
Casecading dropdown using JQuery.
1) Put the following JavaScript function on the page:
function BindDropDown(dropdown_parent,dropdown_child,selectedVal)
{
if(document.getElementById(dropdown_parent).selectedIndex>0)
{
$.ajax
({
url: "/GetAjaxData.aspx",
data: "type=products&value="+document.getElementById(dropdown_parent).options[document.getElementById(dropdown_parent).selectedIndex].value,
success: function(message1)
{
var selectedindex=0;
var rows1 = message1.split("\n");
var iCount = 0;
document.getElementById(dropdown_child).options.length = 0;
for (iCount = 0; iCount < rows1.length; iCount++)
{
var valu=rows1[iCount].split("|");
if(valu[1].replace(/^\s*/, "").replace(/\s*$/, "")==selectedVal)
selectedindex=iCount;
var oOption = new Option(valu[0],valu[1].replace(/^\s*/, "").replace(/\s*$/, ""));
document.getElementById(dropdown_child).options.add(oOption);
}
document.getElementById(dropdown_child).options[selectedindex].selected=true;
return false;
}
});
}
else
{
document.getElementById(dropdown_child).options.length = 0;
document.getElementById(dropdown_child).options.add(new Option("--Select--", "0"));
}
}
2) Call The Following function on dropdown's selected index change:
BindProducts('<%=ddlParent.ClientID%>', '<%=ddlChild.ClientID%>', '<%=Id%>')
3) Put the following code on the GetAjaxData.aspx page:
2) Call The Following function on dropdown's selected index change:
BindProducts('<%=ddlParent.ClientID%>', '<%=ddlChild.ClientID%>', '<%=Id%>')
3) Put the following code on the GetAjaxData.aspx page:
protected void Page_Load(object sender, EventArgs e)
{
ReturnDDLData(Convert.ToInt32(Request.QueryString["value"]));
}
private void ReturnDDLData(Int32 selectedId)
{
Response.Clear();
StringBuilder sbResponse = new StringBuilder();
Collection m_oCollection = new Collection();
m_oCollection.GetCollection(selectedId);
sbResponse.Append(string.Concat("--Select--", "|0", Environment.NewLine));
foreach (Product m_oItem in m_oCollection)
{
sbResponse.Append(string.Concat(m_oItem.Name, "|", m_oItem.ID.Value.ToString().Trim()) + Environment.NewLine);
}
Response.Output.Write(sbResponse.ToString().Substring(0, sbResponse.ToString().LastIndexOf(Environment.NewLine)));
Response.End();
}
Create a Windows Service in .net
Hi,
Following are the steps to create a basic windows service to write a file in .net:
include following namespaces:
using System.Text;
using System.IO;
using System.Timers;
Create a class level timer:
private Timer timer = new Timer();
On Start Event:
protected override void OnStart(string[] args)
{
timer.Elapsed += new ElapsedEventHandler(TimerElapsed);
timer.Interval = 10000;
timer.Enabled = true;
}
Create Event handler:
private void TimerElapsed(object source, ElapsedEventArgs e)
{
Logger();
}
Create function:
public void Logger()
{
string mydocument =
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string[] txtList = Directory.GetFiles(mydocument, "*.txt");
StringBuilder sb = new StringBuilder();
string FileName = @"\log.txt";
using (StreamReader sr = new StreamReader(mydocument + FileName))
{
sb.AppendLine(DateTime.Now.ToString());
sb.AppendLine("---------------------------------------------");
sb.Append(sr.ReadToEnd());
sb.AppendLine();
}
using (StreamWriter outfile =
new StreamWriter(mydocument + FileName))
{
outfile.Write(sb.ToString());
}
}
InstallUtil command to install the service:
installutil ServicePath/Servicename.exe
To uninstall the service:
installutil /u ServicePath/Servicename.exe
Custom Validator in JQuery.Validate
$.validator.addMethod(
"regexName",
function(value, element) {
var check = false;
var re = new RegExp('^[a-zA-Z _0-9.]+$');
return this.optional(element) || re.test(value);
},
"No special characters allowed!"
);
rules: {
LoginName: {
required: true,
regexName:true
},
"regexName",
function(value, element) {
var check = false;
var re = new RegExp('^[a-zA-Z _0-9.]+$');
return this.optional(element) || re.test(value);
},
"No special characters allowed!"
);
rules: {
LoginName: {
required: true,
regexName:true
},
Open fancybox on Input Click
1)
$(document).ready(function()
{
$("#BTN").click(function()
{
$('test desc').fancybox().click();
});
});
2)
$("#buttontoclick").click(function() {
$('Friendly description').fancybox({
overlayShow: true
}).click();
});
3)
function OpenPage(id) {
$('dummy_anchor').fancybox({
'frameWidth': 420, 'frameHeight': 413 // 'frameHeight': 232
}).click();
}
$(document).ready(function()
{
$("#BTN").click(function()
{
$('test desc').fancybox().click();
});
});
2)
$("#buttontoclick").click(function() {
$('Friendly description').fancybox({
overlayShow: true
}).click();
});
3)
function OpenPage(id) {
$('dummy_anchor').fancybox({
'frameWidth': 420, 'frameHeight': 413 // 'frameHeight': 232
}).click();
}
JS file with Server Side Variable
Javascript object and class concept
<_script_start>
var path = {
currentUrl: "",
getPath: function() {
return this.currentUrl;
},
TEST: function() {
alert(this.currentUrl);
}
}
script type="text/javascript">
path.currentUrl = '';
path.TEST();
<_script_start>
var path = {
currentUrl: "",
getPath: function() {
return this.currentUrl;
},
TEST: function() {
alert(this.currentUrl);
}
}
script type="text/javascript">
path.currentUrl = '';
path.TEST();
authorized.net complete
after including previous four classes call this function on button click
private void DoPayment()
{
AuthorizeNetRequest objAuthorizeNetRequest = new AuthorizeNetRequest();
// This is the account information for merchant account given by Authorize.Net people in email
// I can see transaction history here.
objAuthorizeNetRequest.Login = LOGINID;
objAuthorizeNetRequest.Amount = Convert.ToDouble(txtAmount.Text);
objAuthorizeNetRequest.CardNumber = txtCreditCardNo.Text;
objAuthorizeNetRequest.CardExpirationDate = drpExpirationDate.SelectedValue + drpYear.SelectedValue.Substring(2);
objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.AUTH_CAPTURE;
///transaction types
///default is auth capture
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.AUTH_ONLY;
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.CREDIT;
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.VOID;
///we can use other types but will have to provide transaction id if we are going to
///PRIOR_AUTH_CAPTURE type as this will capture prior authorized transaction.
//objAuthorizeNetRequest.TransactionId = "";
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.PRIOR_AUTH_CAPTURE;
objAuthorizeNetRequest.CcvNumber = txtCCV.Text;
// Below is the API created by me by registering for test account.
objAuthorizeNetRequest.TransactionKey = TRANSACTION_KEY;
AuthorizeNetFields allFields = new AuthorizeNetFields();
allFields.x_First_Name = txtCardName.Text;
allFields.x_Address = "";
allFields.x_City = "";
allFields.x_State = "";
allFields.x_Country = "U.S.A";
allFields.x_Phone = "";
allFields.x_Zip = "";
allFields.x_Tax = "";
allFields.x_Email = "";
allFields.x_Description = "";
allFields.x_Ship_to_first_name = txtCardName.Text;
allFields.x_Ship_to_address = "";
allFields.x_Ship_to_city = "";
allFields.x_Ship_to_state = "";
allFields.x_Ship_to_country = "U.S.A";
allFields.x_Ship_to_phone = "";
allFields.x_Ship_to_zip = "";
AuthorizeNetResponse objAuthorizeNetResponse = AuthorizeNet.CallAuthorizeNetMethod(objAuthorizeNetRequest, allFields);
if (objAuthorizeNetResponse.IsSuccess)
{
Response.Write(objAuthorizeNetResponse.SuccessMessage +" ID:"+ objAuthorizeNetResponse.TransactionId);
}
else
{
Response.Write("Error : " + objAuthorizeNetResponse.Errors);
}
}
private void DoPayment()
{
AuthorizeNetRequest objAuthorizeNetRequest = new AuthorizeNetRequest();
// This is the account information for merchant account given by Authorize.Net people in email
// I can see transaction history here.
objAuthorizeNetRequest.Login = LOGINID;
objAuthorizeNetRequest.Amount = Convert.ToDouble(txtAmount.Text);
objAuthorizeNetRequest.CardNumber = txtCreditCardNo.Text;
objAuthorizeNetRequest.CardExpirationDate = drpExpirationDate.SelectedValue + drpYear.SelectedValue.Substring(2);
objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.AUTH_CAPTURE;
///transaction types
///default is auth capture
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.AUTH_ONLY;
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.CREDIT;
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.VOID;
///we can use other types but will have to provide transaction id if we are going to
///PRIOR_AUTH_CAPTURE type as this will capture prior authorized transaction.
//objAuthorizeNetRequest.TransactionId = "";
//objAuthorizeNetRequest.TransactionType = AuthorizeNet.TransactionType.PRIOR_AUTH_CAPTURE;
objAuthorizeNetRequest.CcvNumber = txtCCV.Text;
// Below is the API created by me by registering for test account.
objAuthorizeNetRequest.TransactionKey = TRANSACTION_KEY;
AuthorizeNetFields allFields = new AuthorizeNetFields();
allFields.x_First_Name = txtCardName.Text;
allFields.x_Address = "";
allFields.x_City = "";
allFields.x_State = "";
allFields.x_Country = "U.S.A";
allFields.x_Phone = "";
allFields.x_Zip = "";
allFields.x_Tax = "";
allFields.x_Email = "";
allFields.x_Description = "";
allFields.x_Ship_to_first_name = txtCardName.Text;
allFields.x_Ship_to_address = "";
allFields.x_Ship_to_city = "";
allFields.x_Ship_to_state = "";
allFields.x_Ship_to_country = "U.S.A";
allFields.x_Ship_to_phone = "";
allFields.x_Ship_to_zip = "";
AuthorizeNetResponse objAuthorizeNetResponse = AuthorizeNet.CallAuthorizeNetMethod(objAuthorizeNetRequest, allFields);
if (objAuthorizeNetResponse.IsSuccess)
{
Response.Write(objAuthorizeNetResponse.SuccessMessage +" ID:"+ objAuthorizeNetResponse.TransactionId);
}
else
{
Response.Write("Error : " + objAuthorizeNetResponse.Errors);
}
}
Subscribe to:
Posts
(
Atom
)