Link to home
Create AccountLog in
Avatar of Andrew
AndrewFlag for United States of America

asked on

QueryString value issue?

Hello, can someone please help me to understand why this code redirects to the same url with the same querystring value regardless of what I key into txtSearch.txt?  I need it to update the searchstring via the querystring value.  In this case it constantly redirects to whatever the inital value is that I supply it, never changing when I key a new value into txtSearch.txt.

User generated image
 http://www.xyz.org/seedtracker/Search.aspx?STID=11347
 
 
 Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

       If Request.QueryString("STID") IsNot Nothing Then

            txtSearch.Text = Request.QueryString("STID")

            Dim sSearchString As Integer = CInt(Trim(txtSearch.Text))
            
            txtSearch.Focus()
            
       End If
 
 End Sub
       
 Protected Sub txtSearch_TextChanged(sender As Object, e As System.EventArgs) Handles txtSearch.TextChanged
 
           'Barcode entered for search
           Dim sSearchString As Integer = CInt(Trim(txtSearch.Text))
       
           Response.Redirect("Search.aspx?STID=" & sSearchString)      
           
 End Sub

Open in new window


TIA,
Andrew
Avatar of kaufmed
kaufmed
Flag of United States of America image

I don't believe indexing a QueryString value can ever be Nothing. Try using the following instead:

..
If Not String.IsNullOrWhitespace(Request.QueryString("STID")) Then
...

Open in new window

Avatar of Andrew

ASKER

Thanks for reply... but same result with your suggestion.
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Andrew

ASKER

Thank you! That is what I was missing.