Add a Sub (or function/method) to aspx page on onclick event of LinkButton control to redirect with querystring variable (as in a site-wide search box)

the script for the onclick within an aspx page and not in code-behind in order to redirect to another page with querystring variable
 <script language="VB" runat="server">
        Protected Sub lnkSearch(ByVal sender As Object, ByVal e As EventArgs)
            Dim searchText As String = ""
            If txtBoxSearchText1.Text <> "" Then
                searchText = txtBoxSearchText1.Text
            End If
            If txtBoxSearchText2.Text <> "" Then
                searchText = txtBoxSearchText2.Text
            End If
            If searchText <> "" Then
                Response.Redirect("Search.aspx?searchText=" & searchText)
                'no searchText
            End If
        End Sub
The aspx/html of the control
<asp:LinkButton ID="linkBtnLarge" runat="server" OnClick="lnkSearch">
     <span class="bgSSILightGreen" >
            <span class="glyphicon glyphicon-search white" >
Tags: LinkButton, response.redirect, script
Last update:
2014-10-20 22:44
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category