| | |
How to get auto calculated expiry date on lost focus event of registration date
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2005
Posts: 8
Reputation:
Solved Threads: 0
Hello There,
I am working with c# & I have used two textbox server control.
1> Registration Date
2> Expiry Date
First of all, user enters value for the first textbox namely Registration Date and then the expiry date should be auto calculated by adding 30 days into currently entered registration date when he user leaves the first textbox.
That means there are two textboxes - user enters the value for first textbox and the second textbox should be auto calcuated on lost focus event of first textbox.
So pls let me know..... Waiting for your answer....
Thanks,
Paresh
I am working with c# & I have used two textbox server control.
1> Registration Date
2> Expiry Date
First of all, user enters value for the first textbox namely Registration Date and then the expiry date should be auto calculated by adding 30 days into currently entered registration date when he user leaves the first textbox.
That means there are two textboxes - user enters the value for first textbox and the second textbox should be auto calcuated on lost focus event of first textbox.
So pls let me know..... Waiting for your answer....
Thanks,
Paresh
•
•
Join Date: Oct 2005
Posts: 5
Reputation:
Solved Threads: 0
Re: How to get auto calculated expiry date on lost focus event of registration date
0
#2 Oct 24th, 2005
Dear friend,
There are two ways of doing it. One on the client side and the other one is server side.
On client side, you javascript's method Onblur event of textBox and call a javascript method that gets value from one TextBox and sets the value in second one. So the code like following:
<input type="text" id="register" OnBlur="SetExpiryDate()" />
<input type="text" id="expired" value="" />
and in head section of page add:
<script language="javascript">
//assuming dates are seperated by '/' and is in MM/DD/YYYY
var Date1Split = document.getElementById('register').value.split('/');
var dte = new Date;
dte.setMonth(dte[0]);
dte.setDate(dte[1]);
dte.setFullYear(dte[2]);
//Calculate the expiry date
var expiryDate ;//add logic to calculate the expiry date..left for u
//set the text of textBox expire
document.getElementById('register').value = expiryDate.getMonth() + '/' + expiryDate.getDate() + '/' + expiryDate.getFullYear();
</script>
on server side you can do it easily by adding an event handler, or by just calling post back to page on OnBlur Event by calling __doPostBack('','');
and on server side do expire.Value = DateTime.Parse(register.Value).AddDaye(30).ToShortString();
Hope this helps
There are two ways of doing it. One on the client side and the other one is server side.
On client side, you javascript's method Onblur event of textBox and call a javascript method that gets value from one TextBox and sets the value in second one. So the code like following:
<input type="text" id="register" OnBlur="SetExpiryDate()" />
<input type="text" id="expired" value="" />
and in head section of page add:
<script language="javascript">
//assuming dates are seperated by '/' and is in MM/DD/YYYY
var Date1Split = document.getElementById('register').value.split('/');
var dte = new Date;
dte.setMonth(dte[0]);
dte.setDate(dte[1]);
dte.setFullYear(dte[2]);
//Calculate the expiry date
var expiryDate ;//add logic to calculate the expiry date..left for u
//set the text of textBox expire
document.getElementById('register').value = expiryDate.getMonth() + '/' + expiryDate.getDate() + '/' + expiryDate.getFullYear();
</script>
on server side you can do it easily by adding an event handler, or by just calling post back to page on OnBlur Event by calling __doPostBack('','');
and on server side do expire.Value = DateTime.Parse(register.Value).AddDaye(30).ToShortString();
Hope this helps
![]() |
Similar Threads
- To display data in textbox and label (Visual Basic 4 / 5 / 6)
- Select Query Problem in access (MS Access and FileMaker Pro)
- Detect USB Barcode readers and capture input (Visual Basic 4 / 5 / 6)
- Simple Date in Formview not posting. (ASP.NET)
- Want to initialise text box on basis of another textbox value. (ASP.NET)
- Deleting TextBox'es cause application losing foucs (C#)
- Can Someone please check my project & comment/tips (C)
Other Threads in the ASP.NET Forum
- Previous Thread: regarding project in asp.net
- Next Thread: Help with Roles Stored in SQL database
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iis javascript jquery list listbox menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming wizard xml xsl





