关于Javascript改变readonly的服务端控件的值

在开发中遇到过这种问题

function change()

{

  document.getlementid("txt").value="343";

}

 

<asp:textbox  id ="txt"  ReadOnly="true"></asp:textbox>

这种情况下  textbox的值是不会改变的,因为属性   ReadOnly="true"  是在服务端附加的,所以客户端脚本改变不了

 

需要改变textbox的值,需要给控件添加客户端属性

aspx页面   <asp:textbox  id ="txt" ></asp:textbox>

在后台写下  txt..Attributes.Add("readonly", "true");

 

 

 

posted @ 2014-04-26 17:36  我的名字很长很长  阅读(169)  评论(0编辑  收藏  举报