Starr Duskk
asked on
DropDownList with AutoPostBack = True Triggers SelectedIndexChanged on every postback
I have a DropDownList with AutoPostBack = True and set with Handles ddlExportOption.SelectedIn dexChanged
I do not have this event also in code in front, only attached with a Handles to the event.
When I change the value it triggers as expected.
When I change another postback, it still triggers the event.
Does anyone have an example of how you used a DropDownList with an AutoPostBack and that you have got it to NOT trigger when it is NOT the control being changed?
What I #1 would like is not a bunch of "have you trieds" but a known, working solution.
Apparently this is a known issue as I have read and tried numerous things suggested in forums. None of which work.
So that you won't ask "Have you tried...?" Here is what I've tried.
UpdatePanel with AsyncPostBackTrigger on controlId and event name.
DataBind on control on every postback.
Adding EnableViewState="true" to the control and to the page.
I've tried combinations of each of the above.
I've read to try ControlState and Override LoadPostData if I don't wish to EnableViewState. Which I don't mind if I EnableViewState or not, it's just that when I do have it enabled, it still does the postback event anyway and has other unwanted results which I won't go into.
And again...
Does anyone have an example of how you used a DropDownList with an AutoPostBack and that you have got it to NOT trigger when it is NOT the control being changed?
What I #1 would like is not a bunch of "have you trieds" but a known, working solution.
thanks!
I do not have this event also in code in front, only attached with a Handles to the event.
When I change the value it triggers as expected.
When I change another postback, it still triggers the event.
Does anyone have an example of how you used a DropDownList with an AutoPostBack and that you have got it to NOT trigger when it is NOT the control being changed?
What I #1 would like is not a bunch of "have you trieds" but a known, working solution.
Apparently this is a known issue as I have read and tried numerous things suggested in forums. None of which work.
So that you won't ask "Have you tried...?" Here is what I've tried.
UpdatePanel with AsyncPostBackTrigger on controlId and event name.
DataBind on control on every postback.
Adding EnableViewState="true" to the control and to the page.
I've tried combinations of each of the above.
I've read to try ControlState and Override LoadPostData if I don't wish to EnableViewState. Which I don't mind if I EnableViewState or not, it's just that when I do have it enabled, it still does the postback event anyway and has other unwanted results which I won't go into.
And again...
Does anyone have an example of how you used a DropDownList with an AutoPostBack and that you have got it to NOT trigger when it is NOT the control being changed?
What I #1 would like is not a bunch of "have you trieds" but a known, working solution.
thanks!
ASKER
I did try the suggestion to use __EVENTTARGET.
I added it to my selectedindexchanged event like so:
Private Sub ddlExportOption_SelectedIn dexChanged (sender As Object, e As EventArgs) Handles ddlExportOption.SelectedIn dexChanged
Dim postbackevent As String = HttpContext.Current.Reques t.Form("__ EVENTTARGE T")
If InStr(postbackevent, "ddlExportOption") > 0 Then
ddlExportOptionSelectedInd exChanged( )
End If
End Sub
And it is working and also exports the excel document and opens excel, but you would think that Microsoft would have a solution to handle their issue.
I added it to my selectedindexchanged event like so:
Private Sub ddlExportOption_SelectedIn
Dim postbackevent As String = HttpContext.Current.Reques
If InStr(postbackevent, "ddlExportOption") > 0 Then
ddlExportOptionSelectedInd
End If
End Sub
And it is working and also exports the excel document and opens excel, but you would think that Microsoft would have a solution to handle their issue.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlExportOption" name="ddlExportOption" runat="server">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlExportOption
</Triggers>
</asp:UpdatePanel>
I'm trying to trigger the event to open an Excel Spreadsheet in Excel. Not only does the above ALSO not work and does an unwanted postback, but it also totally ignores sending the file, which works fine without the UpdatePanel.