locked
How do I update a button PostBackURL depending on the Drop Down Box Value RRS feed

  • Question

  • User-1473228408 posted

    Hey,

    I'm making a search function using a drop down box (SearchDrop), text box (TxtBSearch) and a button (BtnSearch).

    Now the main issue is that when i select the button it will make the drop down text to the postbackurl like this

            If SearchDrop.Text = "Genre" Then
                BtnSearch.PostBackUrl = "~/SGenre.aspx"
    
            ElseIf SearchDrop.Text = "Film" Then
                BtnSearch.PostBackUrl = "~/SFilm.aspx"
            End If
    
            If TxtBSearch.Text = Nothing Then
                BtnSearch.PostBackUrl = ""
            End If
     

    However when i use this im it will first have to refresh the page before this takes effect.

    is their any way to refresh that section ?

    Thursday, March 1, 2012 3:10 PM

Answers

  • User-439404275 posted

    You could employ an UpdatePanel from the .net Ajax.

    <asp:UpdatePanel id="updButton" runat="server">

    <ContentTemplate>

    <asp:Button id="BtnSearch" runat="Server" Text="My Button" />

    </ContentTemplate>

    <Triggers>

    <AsyncPostBackControl ControlId="SearchDrop" Event="SelectedIndexChanged" />

    </Triggers>

    </asp:UpdatePanel>

     

    Or you could this on the client using javascript/jquery.

     function UpdateButton() {

      var value = $("#SearchDrop").val();

      if ..

       $("#btnSearch").PostBackUr('~/Genre.aspx'); 

    }

    <select id="SearchDrop" onchange="UpdateButton" clientidmode="Static" /> 

    Or some such, should be close.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 1, 2012 3:27 PM