Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Redirect; string truncates at "&"

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
I have a page redirect from a linkbutton like below.
Code:
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim Comp As String = Me.ListBox1.SelectedValue.ToString
        Dim Dept As String = Me.ListBox2.SelectedValue.ToString
        Response.Redirect("ShowDeptDocs.aspx?Comp=" + Comp + "&Dept=" + Dept)
    End Sub
Then in the load event of the "ShowDeptDocs" page I have this code to get the strings
Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim Comp As String = Request.QueryString("Comp").ToString()
        Dim Dept As String = Request.QueryString("Dept").ToString()
        Me.LabelDisplay.Text = "Detalis of > " & Comp & " > " & Dept
    End Sub

It is working fine if there is no "&" in the string. If there is any "&" in the string then it truncates from there.
Eg:
Code:
Comp="XYZ & Co"
Dept="This & That dept"

This will pass only
Code:
Comp= "XYZ" 
Dept= "This"
as strings.

Is there any idea not to truncate the string or any other way to redirect the page.

thanks


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
You'll have to encode the strings as you pass them through and then decode them at the other end. Try this:
Code:
Dim Comp As String =  Server.UrlEncode(Me.ListBox1.SelectedValue.ToString)
Dim Dept As String =  Server.UrlEncode(Me.ListBox2.SelectedValue.ToString)
Code:
Dim Comp As String = Server.UrlDecode(Request.QueryString("Comp").ToString())
Dim Dept As String = Server.UrlDecode(Request.QueryString("Dept").ToString())




____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Excellent!!!
That done the job.

Thanks


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top