首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

奇怪,服务器标记总是被转义了解决方法

2012-01-03 
奇怪,服务器标记总是被转义了我在后台给RadioButtonList添加一个事件this.rbMode.Attributes.Add( onclic

奇怪,服务器标记总是被转义了
我在后台给RadioButtonList添加一个事件
this.rbMode.Attributes.Add( "onclick ",   "JsSel( ' <%=this.ClientID   %> ') ");
在浏览的时候查看源代码   就变成了这样
  <span   id= "ctl00_ContentPlaceHolder1_rbMode "   onclick= "JsSel( '&lt;%=this.ClientID%> ') "> <input   id= "ctl00_ContentPlaceHolder1_rbMode_0 "   type= "radio "   name= "ctl00$ContentPlaceHolder1$rbMode "   value= "1 "   checked= "checked "   />
即JsSel( ' <%=this.ClientID   %> ')变成JsSel( '&lt;%=this.ClientID%> ')
<   总是转义成   &lt;     想不通是哪里的原因。有没有人遇到这种情况


[解决办法]
同意楼上的
把对象传过去更好
[解决办法]
this.rbMode.Attributes.Add( "onclick ", "JsSel(this.id) ")如果不想改JS的话


[解决办法]
这种代码只能在客户端用,在服务器段为什么这么用,直接这么写不就行了

this.rbMode.Attributes.Add( "onclick ", "JsSel( ' " + rbMode.ClientID + " ') ");

热点排行