468,773 Members | 2,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,773 developers. It's quick & easy.

How to get the today date on page load into the readonly text box

Hi
I have a readonly textbox i want to put the today date in there on th epage load but don't have any idea how to getthe dat inthere please help me
here is my code:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page language="c#" Codebehind="Accomplishment.aspx.cs" AutoEventWireup="false" Inherits="Accomplishments.Accomplishment" %>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
  3. <HTML>
  4.     <HEAD>
  5.         <title>Accomplishment</title>
  6.         <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  7.         <meta name="CODE_LANGUAGE" Content="C#">
  8.         <meta name="vs_defaultClientScript" content="JavaScript">
  9.         <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  10.     </HEAD>
  11.     <body>
  12.         <form id="Form1" method="post" runat="server">
  13.             <table height="100%" cellSpacing="0" width="700" align="center" border="1">
  14.                 <tr>
  15.                     <td height="50"><IMG src="header.jpg" width="700"></td>
  16.                 </tr>
  17.                 <tr>
  18.                     <td vAlign="top">
  19.                         <table cellPadding="5" width="700">
  20.                             <tr>
  21.                                 <td>
  22.                                     FirstName:
  23.                                     <asp:TextBox ID="txtFirstName" Runat="server"></asp:TextBox>
  24.                                     LastName:
  25.                                     <asp:TextBox ID="txtLastName" Runat="server"></asp:TextBox></td>
  26.                             </tr>
  27.                             <tr>
  28.                                 <td>
  29.                                     DateCreated: 
  30.                                     <asp:TextBox ID="txtdatecreated" Runat="server" ReadOnly="True"></asp:TextBox>
  31.                                     ProejctName:
  32.                                     <asp:TextBox ID="txtProject" Runat="server"></asp:TextBox>
  33.                                     <asp:dropdownlist id="drpMonth" AutoPostBack="True" Runat="server">
  34.                                         <asp:ListItem Value="">Select a Month</asp:ListItem>
  35.                                         <asp:ListItem Value="01">January</asp:ListItem>
  36.                                         <asp:ListItem Value="02">February</asp:ListItem>
  37.                                         <asp:ListItem Value="03">March</asp:ListItem>
  38.                                         <asp:ListItem Value="04">April</asp:ListItem>
  39.                                         <asp:ListItem Value="05">May</asp:ListItem>
  40.                                         <asp:ListItem Value="06">June</asp:ListItem>
  41.                                         <asp:ListItem Value="07">July</asp:ListItem>
  42.                                         <asp:ListItem Value="08">August</asp:ListItem>
  43.                                         <asp:ListItem Value="09">September</asp:ListItem>
  44.                                         <asp:ListItem Value="10">October</asp:ListItem>
  45.                                         <asp:ListItem Value="11">November</asp:ListItem>
  46.                                         <asp:ListItem Value="12">December</asp:ListItem>
  47.                                     </asp:dropdownlist>
  48.                                 </td>
  49.                             </tr>
  50.                             <tr>
  51.                                 <td>
  52.                                     <asp:TextBox ID="txtdescription" Runat="server" Width="600" Height="150" TextMode="MultiLine"></asp:TextBox>
  53.                                 </td>
  54.                             </tr>
  55.                             <tr>
  56.                                 <td>
  57.                                     <asp:Button ID="cmdSubmit" Text="Submit" Runat="server"></asp:Button>
  58.                                 </td>
  59.                             </tr>
  60.                         </table>
  61.                     </td>
  62.                 </tr>
  63.             </table>
  64.         </form>
  65.     </body>
  66. </HTML>
  67.  
  68.  
if any one know about this please help me
Oct 2 '07 #1
2 1862
nateraaaa
663 Expert 512MB
In the page_load event of your code behind you need the following code

Expand|Select|Wrap|Line Numbers
  1. txtdatecreated.Text = DateTime.Now.ToShortDateString();
Nathan
Oct 2 '07 #2
Thanks very much it helped for for me alot thanks verymuch once again
take care
Oct 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Philip Rayne | last post: by
reply views Thread by Jeff | last post: by
4 posts views Thread by Kun | last post: by
4 posts views Thread by Tamichan | last post: by
6 posts views Thread by dean.h.brown | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.