Saturday, 1 February 2014

How to set TextBox as readonly in AJAX Calendar Extender?

How to set TextBox as readonly in AJAX Calendar Extender?
Read only controls are not posted back to the server.
In postback you will lose the value in a read only control.
So, you can set the ReadOnly=False on your TextBox to use the following code.
C#.Net
protected void Page_Load(object sender, EventArgs e)
{
    txtFromDate.Attributes.Add("readonly", "readonly");
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    txtFromDate.Attributes.Add("readonly", "readonly")

End Sub

Trick Questions:

If you set readonly=true in TextBox, you not get the value in postback.

0 comments:

Post a Comment