GET ERROR无法修改Controls集合,因为控件包含代码块(即)。 [英] GET ERROR The Controls collection cannot be modified because the control contains code blocks (i.e. ).

查看:76
本文介绍了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) + ")");

          }
      }





< b>

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

推荐答案

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


将代码块替换为<%#而不是<%=



参考



aspnet-controls-collection-can-not [< a href =http://www.aspdotnet-suresh.com/2011/12/aspnet-controls-collection-cannot-be.htmltarget =_ blanktitle =New Window> ^ ]



所述的控件收集-不能待改性因为-的控制-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集合,因为控件包含代码块(即)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆