我的aspx页面中有一个输入元素。
<input id="txtAllocAmt" type="text" class="txtAllocAmt" tabindex="2" size="10" name="Text1"
runat="server" disabled="disabled" onfocus="javascript:SetOldAllocAmt(this.id);"
onblur="ValidateAllocAmt(this.id);" />
问题在于,出于某种原因,当代码运行时,javascript调用“onfocus”和“onblur”都不会显示出来,如下所示。
<input onblur="" onfocus="" id="lvLienAllocations_ctrl0_ctl00_txtAllocAmt" class="txtAllocAmt" tabIndex="2" name="lvLienAllocations$ctrl0$ctl00$txtAllocAmt" size="10" type="text">
出于某种原因,“onblur”和“onfocus”被设置为空字符串。
什么阻止asp.net代码生成器生成这些javascript调用?
答案 0 :(得分:2)
删除runat = server,或者在代码后面添加事件:
lvLienAllocations.Attributes.Add("onblur", "javascript:SetOldAllocAmt(" + lvLienAllocations.ClientID + ")";