patsrule327
New Member
I am having a heck of a time trying to figure out how to insert a default text string into an asp:textbox control.<BR><BR>Essentially, I am providing two text boxes for two date ranges; a start date and an end date.<BR><BR>I want the end date text box to contain today's date, as most searches on my data will be for the most-recent data, however, I want the user to be able to specify an end date other than the current date.<BR><BR>This should be pretty darned simple, but it's beating me about the head.<BR><BR>Any help is greatly appreciated!To assign a default value for a textbox control, you use either value=http://aspmessageboard.com/archive/index.php/"some text" or text="some text", like this...<BR><BR><asp:TextBox id="TextBox1" text="some text here" runat="server"/><BR><BR>I was playing with trying to get the date in the textbox, and this is the only way I could come up with...but I'm a relative newb so someone else may know a better way.<BR><BR><%@ Page Language="VB" %><BR><BR> <html><BR> <head><BR> <script language="VB" runat="server"><BR> Sub SetDate(Sender As Object, e As EventArgs)<BR> TextBox1.Text = (Date.Now).ToShortDateString<BR> End Sub<BR> </script><BR> </head><BR> <body><BR> <h3>TextBox Sample</h3><BR> <form runat="server"><BR> <asp:TextBox id="TextBox1" onLoad="SetDate" runat="server"/><BR> </form><BR> </body><BR> </html><BR><BR>Hope that helps...The textbox control supports text as a property such that:<BR><asp:TextBox id="MyTextBox<BR> Text="Default Text"<BR> runat="server"<BR> /><BR><BR>To set a date you can call the system date and you'll have to be a little more creative if you want the text box to have an OnFocusEvent, etc.