Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have issues with the script manager and update panels, so first I thought I would add the script manager in code behind for my server control, and then go back and try to solve my first issue.

But the Form in Me.Page.Form is always nothing, use new keyword.

I know how to add stuff to the header in code behind, but the form eludes me.

I just need a knock in the head or something on this one.

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
        MyBase.OnInit(e)

        ' If there is a ScriptManager on the page, use it. If not, then add a ScriptManager.
        Dim SMgr As ScriptManager
        If (ScriptManager.GetCurrent(Page) Is Nothing) Then
            Dim oScriptManagerAjax As ScriptManager
            oScriptManagerAjax = New ScriptManager
            With oScriptManagerAjax
                .ID = "ScriptManager1"
            End With

            Me.Page.Form.Controls.AddAt(0, oScriptManagerAjax)

        Else : SMgr = ScriptManager.GetCurrent(Page)
        End If

End Sub


[edit]

I forget to mention that I'm using asp.net framework 4.0 and master pages, in which the form tag with runat="server" is on the masterpage.

I don't this is possible to do in a server control, after messing with this for another 3 hours after the first post here.
Posted
Updated 18-Jul-13 12:31pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900