C
Cipher
I've built a ASP.Net webpage with a Textbox that is meant to hold a date
chosen from a JavaScript calendar on the page. The default value for this
control is handled during the page load event as follows...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
txtDate.Text = Format(Date.Now, "Long date")
End If
End Sub
Since I don't want the user to manually enter a date (ie they should always
use the calendar control), we have disabled the TextBox by setting it's
Enabled property to false. Unfortunately, this seems to cause the ViewState
to fail for the control whenever the page is posted. Specifically, the
control is always reset to the value in the code snippet above. However, If
we enable the control, its state is saved after the page is posted!
Since we always want the TextBox to maintain its state, is there a way
around this?
Thank you.
chosen from a JavaScript calendar on the page. The default value for this
control is handled during the page load event as follows...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
txtDate.Text = Format(Date.Now, "Long date")
End If
End Sub
Since I don't want the user to manually enter a date (ie they should always
use the calendar control), we have disabled the TextBox by setting it's
Enabled property to false. Unfortunately, this seems to cause the ViewState
to fail for the control whenever the page is posted. Specifically, the
control is always reset to the value in the code snippet above. However, If
we enable the control, its state is saved after the page is posted!
Since we always want the TextBox to maintain its state, is there a way
around this?
Thank you.