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.