How to keep the Text of a Read only TextBox after PostBack()?

前端 未结 7 1132
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 07:05

I have an ASP.NET TextBox and I want it to be ReadOnly. (The user modify it using another control)

But when there is a PostBack()

7条回答
  •  春和景丽
    2020-12-08 07:46

    Another solution I found and easier one:

    Add this to the Page Load method:

    protected void Page_Load(object sender, EventArgs e)
    {
         TextBox1.Attributes.Add("readonly", "readonly");
    }
    

提交回复
热议问题