I want to load date to the text box with full month, this means that the users will get the current date and time every time they want to save the date on the text box. They won't write anything
Here is the format i want "02 November 2015" but am not getting what am looking for. I got this results "DD-NOV-2015" and that's not what am looking for.
Should you know any simple way i can do it using j query,ajax or any,please help
Please see my code below
Page Load
protected void Page_Load(object sender, EventArgs e)
{
this.txtInceptiondate.Text = DateTime.Now.ToString("DD-MMM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToUpper();
}
Saving to the database
protected void tbnSave_Click(object sender, EventArgs e)
{
IList<tblPolicy> _Inception = _dc.tblPolicies.Where(a => a.Name == txtname.Text.ToString()).ToList();
if (_Inception != null)
{
if (_Inception.Count() == 0)
{
tblPolicy _Policy = new tblPolicy
{
Name = txtname.Text,
PolicyName = txtpolicyname.Text,
InceptionDate = txtInceptiondate.Text
};
_dc.tblPolicies.InsertOnSubmit(_Policy);
_dc.SubmitChanges();
lblresults.Visible = true;
lblresults.Text = "Welcome " + txtname.Text + " ! , Your new policy " + txtpolicyname.Text + " is well recived!";
txtpolicyname.Text = "";
txtname.Text = "";
txtInceptiondate.Text = "";
}
}
}
There is no
DD
as a custom date and time specifier. These specifiers are case sensitive. That's why it reflects itself to the result as it is.You need to use
dd MMMM yyyy
format instead. And don't useToUpper
method since you wantNovember
notNOVEMBER
.Further reading:
Try this out
It will give result in this format 02 November 2015
You can try to use MMMM to get the full name of the month. Check the MSDN. Try this: