文本框的readonly问题,关键字:vs2005,textbox,readonly

   

       

   

    initial text

   

 

 

 

public partial class MyForm : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {           

        TextBox1.ReadOnly = true;

    }

 

    protected void Button1_Click(object sender, EventArgs e)

    {

        Response.Write(TextBox1.Text + "
");

       

    }

}

    

 解决:   

1.TextBox1.Attributes["contentEditable"] = "false";

    

2.其实如果是设置客户端属性的话,设置客户端的readonly属性应该也是可以的:

TextBox1.Attributes["readonly"] = "true";

你可能感兴趣的:(.Net经验点滴)