Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear Frnds,

on my webform , I have a Textbox for Issue Date/time.

When i Clicks inside of Textbox...system Date should be displayed in it with DAY, Month ,YEAR Automatically. Please solve this problem.


Thanks,
Posted

Use this code is in page load.....

why system date should display when click, it will show u directly in page load....

Or if u want to click and select better use AJAX tool kit....

C#
tboxDate.Text = DateTime.Now.ToString("MM/dd/yyyy");


I hope u will get your answer.....
 
Share this answer
 
v3
You can try this..
ASP.NET
Date : <asp:textbox id="txtDate" runat="server" clientidmode="Static" xmlns:asp="#unknown"></asp:textbox>
   <script type="text/javascript">
       $(document).ready(function ()
       {
           $("#txtDate").click(function ()
           {
               var Currntdate = new Date();
               $("#txtDate").val(Currntdate.getDay() + "-" + Currntdate.getMonth() + "-" +Currntdate.getYear());
           });
       });
   </script>
 
Share this answer
 
v2
Only using javascript will give the client side date in the etxtbox. If you need client side date then

handle onclick of the textbox and do something like

JavaScript
 var Currntdate = new Date();
$("#txtDate").val(Currntdate.getDay() + "-" + Currntdate.getMonth() + "-" +Currntdate.getYear());



on the other hand of you need server side date then have the server side date written in a hidden field on page load and on click of the text box set the value of textbox to the value of hidden field.
 
Share this answer
 
Comments
Syed SufiyanUddin 18-Apr-12 4:36am    
am unable to understand, please send me code
what have you tried?
search for date formats in google.
 
Share this answer
 
Comments
Syed SufiyanUddin 18-Apr-12 3:33am    
Boss , i need complete date automatically when the user clicks on Textbox. please find a solution fo this.
use javascript for this purpose like:

ASP.NET
<asp:textbox id="txtDate" runat="server" onclick="return SetDate();"></asp:textbox>


JavaScript
function SetDate() {
            var today = new Date();
            document.getElementById('<%= txtDate.ClientID %>').value = today.getDate() + '/' + today.getMonth() + '/' + today.getYear();
            return false;
        }


Regards,
Akaas Developer
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900