views:

63

answers:

1

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>                        
    <asp:ColorPickerExtender ID="txtColorCode_ColorPickerExtender" runat="server" 
        Enabled="True" OnClientColorSelectionChanged="colorChanged" 
        SampleControlID="txtColorCode" TargetControlID="txtColorCode">
    </asp:ColorPickerExtender>
</EditItemTemplate>

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.

A: 

Instead of using Text='<%# Bind("ColorCode") %>' in the markup, create an event handler of the GridView's OnRowDataBound event and set the colour programaticlly in there. That will remove the need for the <% ... %> block and hence the error.

Ben Robinson
I tried removing this tag and tried using text="" it is still showing me error
Shantanu Gupta
Did you do a full rebuild? If so that would either mean you are getting a spurious error "e.g. it is saying that you have `<% ... %>` code blocks when you don't or that you have other code blocks that you have not put in your example.
Ben Robinson
@Ben: Dont know what is happening. Till yesterday everything was ok and working fine. But today when i made a new master page and converted old pages to run in this master page. Then these two pages which contain ColorPicketExtender Control gets hang up. As soon as i removes this control these two pages also start working fine.
Shantanu Gupta