Web Forms :: Excel Export - Controls Collection Cannot Be Modified Because Control Contains Code Blocks
Jan 24, 2012
The code on one of my aspx pages is giving me this error:
I'm getting this on the code behind for export to excel on one of my pages.
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).It is referring to this line Me.GridView1.Parent.Controls.Add(frm)
I have this code in the aspx page. I am using two gridviews. I need to have this on the page any way I can fix the code so I can use that export to excel you created?
<% If(Session("PendingClaims"))%>then display gridview1<%Else%>
Then display gridview2<% End If %>
View 1 Replies
Similar Messages:
Jun 9, 2012
I want use meta tag in my page that read keyword from database
I set this code in my product.aspx page
protected void Page_Load(object sender, EventArgs e) {
SqlCommand _cmd = new SqlCommand("select Keyword1 + ',' + Keyword2 + ',' +Keyword3 from House_info where BehCode=1115", _cn);
_cn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
while (_dr.Read())
[Code] ....
It worked correctly and show my keywords from database and show it in my product.aspx metatag
I have two other page
index.aspx and store.aspx in index.aspx i have 1button and 1 TextBox when user type their BEHCODE(columns name in users table) in TextBox it go to store.aspx page and show that users information on store.aspx
Now i want set meta tag in store.aspx page and i want fill store.aspx meta tag from my users table in data base
This is index.aspx
protected void ImageButton3_Click(object sender, ImageClickEventArgs e) {
string data = Server.UrlEncode(txtNumeric.Text);
SqlCommand _cmd = new SqlCommand("traidname", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.Add("@BehCode", data);
[Code] ....
Here when i run website this error occur
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
In this line
this.Page.Header.Controls.Add(htmlMeta);
I use this code too
<script type="text/javascript">
$("input[id$=btnButton]").live("click", function () {
return confirm("Do you want to submit?");
});
</script>
But it didn't worked this problem just happen here when i used meta tag code in other page it worked correctly . Why this happen?
View 1 Replies
Mar 27, 2011
i saw few of solutions for this exception (like putting it in place holder, or replace the <% to <# ...etc) , but i don't get the idea about it, i mean what is the controls collection? and why it can't be modified if the added control contains code blocks?
View 2 Replies
Aug 11, 2010
I recently put some code <% %> code blocks in my Master Page. Note I've read of the "fix" for either moving things out of <head> or using <%# %> but neither of them work well for my application.
Now the weird thing is that I only get this error on one page of mine. All the other pages seem to work fine, so what actually causes this error? There is nothing I can think of that is unique about this page. It uses the script manager as does other working pages and there is just nothing extraordinary about this page. It does have quite a few custom controls on it, so hunting down what is different in this page is more difficult than usual.
So what actually causes the Controls collection cannot be modified because the control contains code blocks exception?
View 3 Replies
Dec 18, 2012
Error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
I have the following in my master file to load a dynamic seasonal background image:
HTML Code:
<style type="text/css">
body
{
background-image:url("<%=backgroundImage%>");
background-position: top center;
}
</style>
It works fine on most of my pages, but on one it throws the above error.
View 1 Replies
May 7, 2015
I have web.confing file when adding tag page for set theme
After running project i have this error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
<pages theme="Theme" styleSheetTheme="Theme" clientIDMode="AutoID" />
View 1 Replies
Apr 27, 2016
I am getting http exception in of the method of class file (search.aspx.vb) like "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)",
I have tried placing Java script function in the body of Master page from header, whereas I just removed the Java script tag and its contents in search.aspx (as of its not required now). Still getting exception.
I also know that if we have something like this <%= in Java script function we need to replace with <%#. But I don’t have this kind of code in any function.
View 1 Replies
Sep 23, 2010
I was working on an asp.net 3.5 website and used ajaxtoolkit in it and when I use it in my page it was registered as below
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
and it was working well even After I upgraded my wevbsite to .net version 4 but when I started a new website from scratch in vs2010 using .net4 when I use ajax toolkit in this new site it is registered as folowing
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
and when I run the page I get the error The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) I don't Know what is the reason for this. I noticed another thing. in my old website I was using thckbox script by using the files common.js, jquery-1.3.2.js,jquery.thickbox.js and puting them in a Javascript folder ad then registering them in Script manager as following
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Javascript/jquery-1.3.2.js" />
<asp:ScriptReference Path="~/Javascript/jquery.thickbox.js" />
<asp:ScriptReference Path="~/Javascript/common.js" />
</Scripts>
</asp:ScriptManager>
this was working well also but in my new site the jquery file version was jquery-1.4.1.js but also I added the old version f the javascripts files in the built in Scripts folder that is created by default b the new site and followed the same way in registering them in the script managerchange the JavaScript folder to the built in folder Scripts
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery-1.3.2.js" />
<asp:ScriptReference Path="~/Scripts/jquery.thickbox.js" />
<asp:ScriptReference Path="~/Scripts/common.js" />
</Scripts>
</asp:ScriptManager>
but this doesn't work also in the new site I think that there is something diffirent in the 2 case which leads to this change in performance I wish your support and advice about how to solve this matter
View 4 Replies
Apr 16, 2010
I'm receiving this error on a page that previously worked fine, in fact the only change I've made to the page recently was to add another asp:TextBox and asp:RequiredFieldValidator control.
The page already had numerous ASP.NET controls on it, so I cannot see why these extra controls would make a difference, anyway I shall post the code below and hopefully you can see what the error is:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MeetingGenerator.ascx.cs"
Inherits="usercontrols_MeetingGenerator" %>[code]......
View 2 Replies
Apr 13, 2010
Public Class PMRADGrid
Inherits System.Web.UI.GridView
Private Sub PMRADGrid_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
[code]...
View 1 Replies
Oct 22, 2012
I need a list to export in excel and i need the following to achieve in the exported excell
- I need the header of the excel with font bold and size should be 14px of font.
- Other Cell try should be 12px of the font
- Right align the particular column in the excel
View 1 Replies
Feb 7, 2011
I am getting the following error
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
on adding the following code
HtmlGenericControl ctrl = new HtmlGenericControl("NOSCRIPT");
ctrl.InnerHtml = string.Format("<meta http-equiv=REFRESH content=0;URL={0}>", targeturl);
Page.Header.Controls.Add(ctrl);
May be the below script has some problem
<script type="text/javascript" >
function myfunc()
{
var pas,simve,saue,tsh;
pas=document.getElementById('<%=TextBox2.ClientID%>').value;
simve=hex_md5(pas);
saue='<%=Session["saltval"]%>';
var stsh=simve+saue;
tsh=hex_md5(stsh);
document.getElementById('<%=TextBox2.ClientID%>').value=tsh;
}
</script>
View 1 Replies
Dec 14, 2010
[code]....
Above is my select query result. "Select Groupname from table". Now i want to add dynamit row in table which display like follows.
[code]....
so that i can display the combobox with default value '-Select-'. I tried combobox.item.insert(0.'"Select") but it gives error.
"Items collection cannot be modified when the DataSource property is set."
so I am trying to add dynamically into table.
View 5 Replies
Feb 17, 2010
I got 2 listboxes in a window form, one on left and one on right. The 1st listbox have some items while the 2nd listbox is empty. Also there are 2 buttons between the 2 listboxes which used to move item from/to the 1st and 2nd listbox.My problem here is that after I bind the data to the 1st listbox (from a dataTable, using DisplayMember and ValueMember) , and I try to move 1 of the item from this 1st listbox to the 2nd listbox and I want that the selected item is also removed from the 1st listbox by:
lbMembers2.Items. Add(lbMembers1. Text);
lbMembers1.Items. Remove(lbMembers 1.Text);
But the selected item is not removed from the 1st listbox.Also on deselect button when i move item from 2nd listbox to 1st listbox,it displays error message "Items collection cannot be modified when the DataSource property is set."
View 2 Replies
Jan 23, 2010
I am getting this error after I add <head runat="server"> The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
[Code]....
View 2 Replies
Jun 3, 2010
I want to export evrything in a page to excel, it's just the graph that does not export. I used WebChart Control graph which I downloaded [URL]. I've been looking around and found that you must use SaveImage(), but I do not have that option.
protected void excel_Click(object sender, EventArgs e)
{
excel.Visible = false;
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition",
"attachment; filename=CashFlow.xls");
}
View 1 Replies
Nov 8, 2010
i always get this error when ever i use DropdownExtender,Additional information:The Controls collection cannot be modified because the control contains code blocks
i.e. <% ... %>).this is my ASPX Code
[Code]...
View 5 Replies
May 7, 2015
I am following your article to show nested gridview: URL.... Now i want to export the Nested gridview data to the Excel sheet, how to do it.
View 1 Replies
Jul 29, 2010
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
I am using it in Gridview's EditTemplate Field to show color with ajax 3.5
This is my master page hierarchy
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Outer.master.cs" Inherits="Home" %>
<%@ Master Language="C#" MasterPageFile="~/Outer.master" AutoEventWireup="true" CodeFile="FullMid.master.cs" Inherits="FullMid" %>
<%@ Page Title="" Language="C#" MasterPageFile="~/FullMid.master" AutoEventWireup="true" CodeFile="StatusRoomMaster.aspx.cs" Inherits="StatusRoomMaster" %>
Page where I am getting error
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<EditItemTemplate>
<asp:TextBox ID="txtColorCode" runat="server" Text='<%# Bind("ColorCode") %>'></asp:TextBox> [code]....
I am using it under masterpage's -> masterpage's -> page
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
I am using this in outer.master and no update panel has been used.
View 1 Replies
May 21, 2010
I am using a grid, with udpate panel, ajax controls etc.So in my code behind everytime the hit my grid page I am clearing the previous session value stored.I do this:
[Code]....
But sometimes when i navigate to other pages and come back to this page it errors out saying:
" Collection was modified after the enumerator was instantiated."
I am trying to remove a particular session key.
View 3 Replies
Oct 29, 2010
I created this generic method to Bind Controls on my ascx:
[Code]....
I cannot use a for cycle, it must be generic to load several DropDownList or CheckBoxLists on my web user control.
View 1 Replies
May 13, 2010
I am trying to run following, it is giving me error "Collection was modified; enumeration operation may not execute" how can I resolve
[Code]....
View 10 Replies
Jun 10, 2010
How can I export data from a Gridview to excel and once exported the data should be formatted in right to left (arabic) manner. How can I achieve this?
View 2 Replies
Sep 22, 2010
We have the requirement to export the data from the grid excel. We can't install the Excel on the server. The excel generated need to be in the printable format. The excel generated needs to have custom headers, footers, repeatble rows, columns and landscape / portrait orientation style.
View 1 Replies
Jan 22, 2010
I am exporting a gridview in MS Excel as mentioned in the following link:
[URL]
I want to set orientation of excel pages as landscape. Is there any way to do that? Any header information to be added for file being exported to set orientation of pages as landscape?
View 2 Replies