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'.

Who is Participating?
b_levittConnect With a Mentor Commented:
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 (  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:
chrispatonConnect With a Mentor Author 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.