简体   繁体   English

VB.NET页面带有两个自动回发下拉列表

[英]VB.NET page with two autopostback dropdownlists

I have simple VB.NET that contains two database driven dropdownlists. 我有一个简单的VB.NET,其中包含两个数据库驱动的下拉列表。 Each dropdownlist has an autopostback property that will execute a function that takes user to another page. 每个下拉列表都有一个autopostback属性,该属性将执行将用户带到另一个页面的功能。

The problem I have is that if user selects dropdownlist A, is taken to the A page, but then presses back button and selects dropdownlist B, the autopostback will occur for dropdownlist A since dropdownlist A is still selected. 我遇到的问题是,如果用户选择下拉列表A,将带到A页面,然后按返回按钮并选择下拉列表B,则由于下拉列表A仍处于选中状态,因此下拉列表A会自动回发。 Any ideas on how to get around this? 关于如何解决这个问题的任何想法?

I've tried everything I can think of. 我已经尝试了所有我能想到的。 I do reset the dropdownlist and comment out the Response.Redirect code to prove that it does actually reset. 我确实重置了下拉列表,并注释掉Response.Redirect代码以证明它确实重置了。 But then as soon as I put the redirect back in, it loses the reset to unselected ability. 但是,一旦我将重定向重新放回原处,它便失去了重置为未选择功能的能力。 I've seen this "bug" posted elsewhere online, but have not found a solution that works. 我已经在网上其他地方看到过这个“错误”,但是没有找到有效的解决方案。

Protected Sub ddlSearchAward_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlSearchAward.SelectedIndexChanged

    Dim strParam As String
    strParam = ddlSearchAward.SelectedItem.Value


    Response.Redirect("awards_?criteria=" & strParam)
End Sub


Protected Sub ddlAwardList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlAwardList.SelectedIndexChanged

    Dim strParam As String
    strParam = ddlAwardList.SelectedItem.Value


    Response.Redirect("awards_?id=" & strParam)

End Sub

我不得不放弃自动回发,并在每个下拉列表旁边放置一个按钮才能使其正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM