The Controls collection cannot be modified because the control contains code blocks
原来我在网页中的client javascript ,使用了 <%=%>,如下
- var strUrl = "InvoiceDisplayFieldSetting.aspx?oid=<%=OID%>";
- window.showModalDialog(strUrl,"setField",
- "dialogWidth:400px;dialogHeight:630px;
- center:1;scroll:0;help:0;status:0;resizable=0");
- }
在 html 中的不会有问题, 但使用了<head runat=”server”> 后, client side javacript 就不能使用
解法是override OnInit()
如下
- override protected void OnInit(EventArgs e)
- {
- base.OnInit(e);
- Page.DataBind();
- }
然后在 client side javacript ,改用 <%# OID%>
大功告成
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步