asp.netvb.netuser-controlspostback

VB.NET if button1 caused post back then


I have a situation where I need to ignore parts of page load sub inside a isPostback = true. Basically inside the isPostBack I want something like if button1 caused postback.... do this else do this...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If IsPostBack = True Then

        If TextBox1.Text <> String.Empty Then

            CheckDate()
        End If

    End If


End Sub

Solution

  • I think what you need is the reference to the control name which triggered the postback.

    Link

    Implement the solution which is there in the above link (Got it from here.... How to Get Source of postback)

    If the control name is your button then do not do what needs to be done upon postback.

    HTH