• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 477
  • Last Modified:

Registering UserControl in codebehind receives parser error exception on calendar click

I have a control registered on a page using;

<%@ Register Src="~/Controls/33pd.ascx" TagName="pd" TagPrefix="pd3" %> at the top of the page and
<pd3:pd id="pd" runat="server"></pd3:pd> where I need the control to be displayed

Which all works fine and no issues the control includes a grid view and tabconatiners displaying data and another control with a asp:calendar displaying data from a database inside an updatepanel.

I need to be able to add the 33pd.ascx control dynamically from the codebehind so I can display different versions of the 33pd.ascx.

I have this code which displays the different controls and loads the controls on the page;
            Control uc = null;

                if (dsPropCheck.Tables[0].Rows[0]["Source"].ToString() == "33")
                    uc = Page.LoadControl(Request.ApplicationPath + "/Controls/33pd.ascx");
                    else if (dsPropCheck.Tables[0].Rows[0]["Source"].ToString() == "22")
                        uc = Page.LoadControl(Request.ApplicationPath + "/Controls/22pd.ascx");
                    else if (dsPropCheck.Tables[0].Rows[0]["Source"].ToString() == "11")
                        uc = Page.LoadControl(Request.ApplicationPath + "/Controls/11pd.ascx");

on page placeholder;
    <asp:PlaceHolder ID="PHPD" runat="server"></asp:PlaceHolder>

but when I click to intereact with the calendar I get this error;

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; InfoPath.2; .NET4.0C)
Timestamp: Sun, 8 May 2011 11:20:30 UTC

Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
<!DOCTYPE html PUB'.

  • 2
2 Solutions
That's an ajax/updatepanel client side error indicating that something is screwy with the response.  My recommendation is to look at the response that comes back with fiddler (www.fiddler2.com).  There's other ways to see the response too but fiddler is the easiest one IMO.

I beleive you could also try turning off partial page rendering and you might get a more specific error message:
chrispatonAuthor Commented:
Fiddler is a nice tool to have, I used this on the page but was not highlighting any issues with the page all loading fine, and nothing coming back when I clicked on the calendar.

Did some more testing and found the problem was I had my code to do the database check to return the different controls within if (!IsPostBack).

Moved the check before the if (!IsPostBack) and the calendar worked fine but this gave me major issues with other jquery tools on the page that had worked previously to trying to add the controls dynamically, all working now.
chrispatonAuthor Commented:
The Fiddler tool was a useful tool to use/suggest for the problem but this did not highlight any issues relating to the problem and found the solution to the problem myself with some more checks after eliminating that all the elements on the page were loading using the tool suggested

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now