GET ERROR无法修改Controls集合,因为控件包含代码块(即)。

编程入门 行业动态 更新时间:2024-10-28 14:28:12
本文介绍了GET ERROR无法修改Controls集合,因为控件包含代码块(即)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Quote:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

我在MasterPage上设置gridview并使用JAVASCRIPT我想做的任务,当我点击gridview的行值存储时隐藏的标志和我想做的事情。 但问题是我调试时发现错误

I set the gridview on MasterPage and using JAVASCRIPT i want to do the task in which , when i click on the Row of gridview the value store into hidden flag and to what i want to do. but the problem is when i debug the error is found

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

i写这段代码// 来自javascript ...

i writing this code// from javascript...

var curSelRowIndex = -1; var curSelRow = null; function GridDblClick(varRowIndex) { debugger; if (curSelRow != null) { curSelRow.style.backgroundColor = (curSelRowIndex % 2 == 0 ? "#EBEBEB" : "activeborder"); } document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].style.backgroundColor = '#ffc0cb'; curSelRow = document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex]; curSelRowIndex = varRowIndex; document.getElementById('<%=hidMID.ClientID %>').value = 'E~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[1]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[2]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[3]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[4]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[5]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[6]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[7]) + '~' + GetInnerText(document.getElementById("<%=GridView1.ClientID %>").rows[varRowIndex].cells[8]); }

代码背后.cs

on code behind .cs

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { e.Row.Attributes.Add("ondblclick", "javascript:return GridDblClick(" + (e.Row.RowIndex + 1) + ")"); } }

主要的事情是我使用这个代码并在MASTERPAGE上放置这个GRIDVIEW .. PLZ建议我为此做什么>>>

推荐答案

一个解决方案可以尝试在正文部分html编写你的javascript代码 one solution could try writing your javascript code in the body section html

将代码块替换为<%#而不是<%= 参考 aspnet-controls-collection-can-not [ ^ ] 所述的控件收集-不能待改性因为-的控制-contains-code-block [ ^ ] Replace the code block with <%# instead of <%= Refer aspnet-controls-collection-cannot-be[^] the-controls-collection-cannot-be-modified-because-the-control-contains-code-block[^]

更多推荐

GET ERROR无法修改Controls集合,因为控件包含代码块(即)。

本文发布于:2023-11-25 00:58:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627661.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   代码   ERROR   Controls

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!