Hey guys...
I have a form that asks for several dates. I tried using asp calendar
controls to set values of the date textboxes which were readonly. I found
this annoying since each time I advanced a month and/or selected any date,
it posted back and refreshed the page. So, instead, I resorted to an old
javascript function I use a lot. The javascript creates a pop up (html)
window and sets the value of the textbox when the user picks a date. I had
done this many times in ASP.NET1. However, since upgrading to .NET2, I
noticed I was getting errors and the data I was trying to pull and save into
a db from the textboxes was coming up as null.
I did a little research and found out that this was a change made in .NET2.
Readonly textboxes can ONLY get their values from Viewstate or serverside
code, NOT client side like javascripts.
http://forums.asp.net/thread/1134316.aspx
The only way I can get my page to work is to set readonly to false (bad
idea). The above thread suggests that I use a PreRender sub for the
textbox(es). The suggestion is from a guy as MS. However, I added this sub
to my vb code behind file and nothing happened. The textbox is still wide
open.
Protected Sub txtStartDate_PreRender(ByVal Sender As Object, ByVal E As
System.EventArgs)
txtStartDate.Attributes("readonly") = "readonly"
End Sub
Any suggestions or advice? I really would like to use my javascript
calendar pop up functions to set the value of the textbox AND I'd like to
keep the txtboxes to readonly (duh). Any advice?
TIA!
-Shane