ASP.net – How to make text box as Read Only

There are two ways of doing it without using javascript:

1) In .aspx side in the declaration of TextBox use the property ReadOnly=“true” and the user wont be able to alter the text box text unless specified from the code behind .cs side.

2)in .cs side where in we can write txtUserName.ReadOnly = true; we can write it  in page load or in button click event or to show default text in text box can supply the text from code behind like this  txtUserName.Text = “Dilip”; where  txtUserName is the ID of the TextBox.

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )