Xpode.com        Click here to Print this article.

How to get value from readonly textbox

I have a situation where user is selecting a date from calendar and With javascript I am entering the value in text boxes (Start date to end date). I am passing the date value in a specific format like mm/dd/yyyy. i am afraid that user may change the value of text box. So i have chnage the property of text box readOnly=True.

Setting the property of Textbox readOnly=True is not a solution. because the server does not perform any processing of ReadOnly textbox controls. To fulfill this requirement you need to use the following code on Page load.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles Me.Load
        txtStartDate.Attributes.Add("readonly", "readonly")
        txtEndDate.Attributes.Add("readonly", "readonly")
End Sub

In HTML

 



http://
http://

Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=153

Click here to go on website