asp.net 的 textbox控件怎么设置readonly属性

asp.net 的 textbox控件怎么设置readonly属性?

如果直接在页面中设置该属性的话,会导致后台代码无法获取到textbox中的值

 

以下方法简单实用:

   protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txt_start.Attributes["readonly"] = "true";
            txt_end.Attributes["readonly"] = "true";
        }
    }

 

即在后台代码的page_load里面设置textbox控件的readonly属性。

你可能感兴趣的:(object,asp.net,textbox)