Control and Postbacks?

  • Thread starter Thread starter Noor
  • Start date Start date
N

Noor

I have two dropdownList controls with AutoPostBack property set to
"True". Everything works fine but I need to find out at the Page_Load
Postback event which dropdownlist control posted the form? Is this
possible with ASP.Net? I searched on the web for this without any
luck.

Any help will be appreciated..

Thanks!
 
On thing you could try is to have a function that runs your 'page load' code
and have it called from the 'SelectedIndexChanged' event on the dropdown.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' Do nothing.

End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged

Response.Write("DD 1 Called!")

Call MyPageLoad(sender, e)

End Sub

Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList2.SelectedIndexChanged

Response.Write("DD 2 Called!")

Call MyPageLoad(sender, e)

End Sub

Private Sub MyPageLoad(ByVal sender As System.Object, ByVal e As
System.EventArgs)

' Handle page loading stuff

End Sub

- Paul Duncan
 
wait... why would you want to? The first thing that will fire is the
SelectedIndexChnaged Event for that... and then the Page_Load will fire...
so, you could set something in the selected index changed event, but I don't
know why you would want to.

-CJ
 
Hi CJ,

I can be wrong of course, but I never saw something else than the pageload
always fires first with a webform

:-)

Cor
 
My bad.. had it backwards... apologies...

-CJ

Cor said:
Hi CJ,

I can be wrong of course, but I never saw something else than the pageload
always fires first with a webform

:-)

Cor
 
Hi CJ,

I only had fun that I saw that you probebly did not see that it was a
webform.And therefore I putted webform on the end..

:-)))

Was a ) to few.

Cor
 
Well I still need the original Page_Load because I have few other
controls in .aspx page beside the dropdownlist controls that I process
in it. I have some other biz logic in the Page_Load event that get
process when Page.isPostback is true.

I don't know if it is possible with ASP.net but easiest thing for me
would be to check which DD list control posted the page.

Once again thanks for the help!
 
Hi Noor,

psuedo code
\\\
load event
if not Is postback then
this is the first time
else
this is every time there is a postback
end if
end sub
dropdownlist1 event
this comes after that load event when dropdownlist1 send
end sub
dropdownlist2 event
this comes after that load event when dropdownlist2 send
end sub
//
I hope this makes it a little bit more clear?

Cor
 
Back
Top