views:

138

answers:

0

My file WebParts.aspx looks like this -

            <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebParts.aspx.cs" Inherits="e.WebParts"  MasterPageFile="~/MasterPage.Master"%>

            <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

            <asp:Content ID="Content2"  
                ContentPlaceHolderID="ContentPlaceHolder1" 
                runat="server">
                <!-- start of create account -->
                <asp:LoginView ID="LoginView1" runat="server">
                    <LoggedInTemplate>
                         <p id="backtoblog"></p>
                         <p> Preferences</p>
                          <div>


                    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" >
                    </asp:ToolkitScriptManager>

                    <div>
                        <asp:TabContainer ID="TabContainer1" runat="server">


                        <asp:TabPanel ID="TabPanel1" runat="server">
                        <ContentTemplate>Page One</ContentTemplate>
                        </asp:TabPanel>

                        <asp:TabPanel ID="TabPanel2" runat="server">
                        <ContentTemplate>Page Two</ContentTemplate>
                        </asp:TabPanel>

                        <asp:TabPanel ID="TabPanel3" runat="server">
                        <ContentTemplate>Page Three</ContentTemplate>
                        </asp:TabPanel>

                        </asp:TabContainer>
                </div>
               </div>
                </LoggedInTemplate>
                    <AnonymousTemplate>
                        You are not logged in.
                        <br />
                        Please login to access eservice
                    </AnonymousTemplate>
                </asp:LoginView>
                <!-- end of create account -->
                </asp:Content>

And it builds just fine but when I publish and execute it, it throws the following exception -

             Script controls may not be registered before PreRender.
            Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

            Exception Details: System.InvalidOperationException: Script controls may not be registered before PreRender.

            Source Error:

            An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

            Stack Trace:

            [InvalidOperationException: Script controls may not be registered before PreRender.]
               System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +349529
               System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +66
               System.Web.UI.ScriptControl.OnPreRender(EventArgs e) +45
               AjaxControlToolkit.ScriptControlBase.OnPreRender(EventArgs e) in d:\hg\act\Server\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:271
               System.Web.UI.Control.PreRenderRecursiveInternal() +80
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Control.PreRenderRecursiveInternal() +171
               System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


            Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3614 

This problem was resolved by inserting the in the master page so that it gets inserted earlier in the page lifecycle as described here -

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/a4f5856a-1c1b-4a07-bc77-782d59e4be82

Adding it in MasterPage.master as follows fixed it -

            <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="e.MasterPage" %>

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

            <html xmlns="http://www.w3.org/1999/xhtml" >
            <head runat="server">
            <title></title>

                <asp:ContentPlaceHolder ID="head" runat="server">
                </asp:ContentPlaceHolder>
            </head>
            <body>


                <form id="form1" runat="server">

                <asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server" />
                    <div>
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

                    </asp:ContentPlaceHolder>
                </div>

                   </div>
                </LoggedInTemplate>
                    <AnonymousTemplate>
                        You are not logged in.
                        <br />
                        Please login 
                    </AnonymousTemplate>
                </asp:LoginView>
                </form>
            </body>
            </html>