Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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

 

Share this article   |    Print    |    Article read by 5161 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: