0

I have a dropdownlist with autopostback and an update panel, it works correctly, but I have also other controls in my page with autopostback. What I need is to control when the page is autopostback but the dropdownlist is not autopostback do something, like this:

     If is not Page.autopostback then
    'do something

else if is not MyDropdownlist.autopostback then    
    ' do something different    
    End if

I can use this:

If is not Page.autopostback then
End If

But I can´t do this:

If is not MyDropdownlist.autopostback then
End If

So how can I do this? I hope my explanation has been helpful, thanks.

Esraa_92
  • 1,558
  • 2
  • 21
  • 48
  • Can you please explain in details what you are trying to achieve exactly? – INDIA IT TECH Mar 09 '16 at 12:19
  • I´m sorry I explain wrong, I want to do some code but only when the page is autopostback but the dropdownlist is not autopostback – Esraa_92 Mar 09 '16 at 12:21
  • May be you use Page.IsPostback property for page postback and check dropdown's selected value. Not sure why you required such thing. Explain clear logic. – INDIA IT TECH Mar 09 '16 at 12:24

1 Answers1

3

The __EVENTTARGET request form variable has the name of control that caused postback to happen. You can query the name of this control and do whatever you want to do.

For example,

If IsPostBack Then
    Dim postBackControlId As String = Request.Form("__EVENTTARGET")
    If Not String.IsNullOrEmpty(postBackControlId) Then
        If postBackControlId = "DropdownList1" Then
            ' the postback happened due to DropdownList1

        Else
            ' the postback happened due to some other control.

        End If
    End If
End If
Pradeep Kumar
  • 6,836
  • 4
  • 21
  • 47
  • Thank you very much for your explanation, It´s works correctly, it was just what I was looking for :-D – Esraa_92 Mar 10 '16 at 08:51