Common Custom controls
Common_CustomControls_VBNet\ADFWebPart\AJAXSharePointWebPart.vb
' Copyright 2010 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text

Namespace ADFWebPart_VBNet
    Public MustInherit Class AJAXSharePointWebPart
        Inherits System.Web.UI.WebControls.WebParts.WebPart
        Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
            MyBase.OnInit(e)

            ' Fix problem with postbacks and form actions (DevDiv 55525)
            Page.ClientScript.RegisterStartupScript(Me.GetType(), Me.ID, "_spOriginalFormAction = document.forms[0].action;", True)

            ' By default, the onsubmit event for forms in SharePoint master pages call "return _spFormOnSubmitWrapper()" 
            ' which blocks async postbacks after the first one.   Not calling "_spFormOnSubmitWrapper()" breaks all postbacks
            ' and defeats the purpose of _spFormOnSubmitWrapper() which is to block repetitive postbacks.  
            ' To call _spFormOnSubmitWrapper() and allow partial postbacks, remove "return" from the original call.  
            If Not Me.Page.Form Is Nothing Then
                Dim formOnSubmitAtt As String = Me.Page.Form.Attributes("onsubmit")
                If (Not String.IsNullOrEmpty(formOnSubmitAtt)) AndAlso formOnSubmitAtt = "return _spFormOnSubmitWrapper();" Then
                    Me.Page.Form.Attributes("onsubmit") = "_spFormOnSubmitWrapper();"
                End If
            End If
        End Sub

    End Class
End Namespace