javascritp problem... handling special char.

G

Guest

hello...

i've got a javascript problem...
my url is created dynamically something like

DeptDetail2.aspx?SubOrgNm=" + SubOrgNm + "&OrgId=" + OrgId + "&SubOrgId=" +
SubOrgId

my problem is that when e.g. suborgnm have the special char of "&" it does
not save this value.. e.g my value would be like this "M&M" it only save M

how can i solve this problem? thanks
 
K

Ken Cox [Microsoft MVP]

Hi Asha,

You need to escape the name to prevent the reserved characters from getting
on the querystring. Use Server.UrlEncode() as shown below?

Dim SubOrgNm As String = "M&M"
Dim OrgId As Integer = 5
Dim SubOrgId As Integer = 10
Response.Redirect("DeptDetail2.aspx?SubOrgNm=" +
Server.UrlEncode(SubOrgNm) + "&OrgId=" + OrgId.ToString + "&SubOrgId=" +
SubOrgId.ToString)

It creates something that looks like this:

DeptDetail2.aspx?SubOrgNm=M%26M&OrgId=5&SubOrgId=10

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top