Home > Asp.net > How to added Script Manager Dynamically before Any Control Need its in asp.net?

How to added Script Manager Dynamically before Any Control Need its in asp.net?

The control with ID ‘updpnlRightNav‘ requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

 

Solution : 

1) Add a PlaceHolder on This Page ThenCreate Event on Update Panel OnInit 

   <asp:PlaceHolderID=”pccScriptManager“runat=”server”></asp:PlaceHolder>

      <asp:UpdatePanelID=”updpnlRightNav“runat=”server” OnInit=”updpnlRightNav_Init”>

2)

   protectedvoid updpnlRightNav_Init(object sender, EventArgs e)

    { 

            if (ScriptManager.GetCurrent(Page) == null)

            {

                //    ScriptManager scriptManager = new ScriptManager

                ScriptManager scriptManager = newScriptManager

                {

                    ID = String.Concat(“ScriptManager”, DateTime.Now.Date.Ticks),

                    EnablePartialRendering = true,

                    ScriptMode = ScriptMode.Release

                };                 if (this.pccScriptManager != null)

                {

                    this.pccScriptManager.Controls.AddAt(0, scriptManager);

                }

            }        

    }

 

Enjoy 🙂

 

 

This Article is TAGGED in , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">