pass value through URL?

Hello Experts

I'm having trouble with something I use all the time.  I have an RS report that uses a navigation field for passing a value through to a .net program I use.  Here is the navigation link we currently use:

="javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum=" & Fields!Expr2.Value & "','_blank'))"

This was going well until I tried passing through Expr2.Value.  This field contains names of customer shops like "John Doe's Parts Co." or "J. Doe's Parts (City Name)".  The javascript I use can't handle "  '  " or  " . " at all, it just gives me a script error on the report when I try to click the navigation link.  For the links that don't contain apostrophes or periods it works.  In the .net program I simply use this to get the correct value:

Sub UrlDecode()
        Dim s, param As String
        Dim i As Integer
        s = Request.RawUrl
        i = s.LastIndexOf("=")
        param = s.Substring(i + 1, s.Length - i - 1)
        param = Server.UrlDecode(param)
        mystr = param
End Sub

Is there a way to edit that javacript link so it works with all characters no matter what appears after /webform1.aspx?ctrlnum=    ?
Help!
jay-areAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ASPSQLServerCOMCommented:
0
brad2575Commented:
Not it will not work like that because the URL can not contain those characters.  

Try using an ID (if possible) for the name in a database table, or before it is put in the URL do what you are doing in the UrlDecode BEFORE it is added to the URL query string.

0
RobinSoftware EngineerCommented:
Can you use the UrlEncode function on the page http://www.albionresearch.com/misc/urlencode.php ?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ASPSQLServerCOMCommented:
0
jay-areAuthor Commented:
Well the javascript link is used in a Reporting Services report.  As far as I know there is no way to add VB code to a report.
0
ASPSQLServerCOMCommented:
To convert a string to the URL-encoded form suitable for transmission as a query string (or, generally speaking, as part of a URL), use the escape function.

http://www.javascripter.net/faq/escape.htm
0
ASPSQLServerCOMCommented:
http://www.dynamicsitesolutions.com/javascript/url-encoding/

click browser view source to get the souce code
0
jay-areAuthor Commented:
So would I try something like this?

="javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum=" & javascript:void(escape(Fields!Expr2.Value)) & "','_blank'))"

I tried putting the second javascript:void in "" and it still gives me an error.
0
scrathcyboyCommented:
The problem is, you need to ESCAPE it when sending via the URL and then UNESCAPE it when the other page receives it -- a 2 step process, normally speaking.  If you cannot run functions on both pages to do this, you will have to pack it into the strings ... either way, and escape() sending and an unescape() receiving, or the equivalent, should get rid of the error.
0
jay-areAuthor Commented:
Well I don't think my link is correct which is why I get the error "Expected end of statement ')'".

0
jay-areAuthor Commented:
Any ideas?  Am I using escape() properly in the link?
0
ASPSQLServerCOMCommented:
try

="javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum=" & (escape(Fields!Expr2.Value)) & "','_blank'))"
0
jay-areAuthor Commented:
[rsCompilerErrorInExpression] The Hyperlink expression for the textbox textbox11 contains an error: [BC30451] Name 'escape' is not declared.

0
ASPSQLServerCOMCommented:
oops

could it be possible to create one variable and assign the escape value to it and then use the variable

which reporting tool you are using

Fields!Expr2.Value -- is your code is in vb.net

0
jay-areAuthor Commented:
Just using VS05 to create the RS reports.  Create a new field using escape()?  Something like
escape(Fields!Expr2.Value)  and call it Fields!Whatever.Value

?
0
jay-areAuthor Commented:
When I try to create a column like that it just literally puts in 'escape(Fields!Expr2.Value)' .  
0
ASPSQLServerCOMCommented:
try

replace
="javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum=" & Fields!Expr2.Value & "','_blank'))"


with

="javascript:var str;str ='../arparentnotes/webform1.aspx?ctrlnum='+ escape(" & Fields!Expr2.Value & ");void(window.open(str,'_blank'))"

or

="javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum=' + escape(" & Fields!Expr2.Value & ") + ','_blank'))"
0
jay-areAuthor Commented:
Both of those end up looking like this:

javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum='%20+%20escape(AUTO%20BATTERY%20&%20IGNITION)%20+%20','_blank'))

Both give ")" expected end of statement errors.
0
ASPSQLServerCOMCommented:
could it be possible for you to call the javascript function instead of directly calling the window.open
0
jay-areAuthor Commented:
Well I need the window.open so that the program opens in a new window, unless you know another way of doing that.
0
ASPSQLServerCOMCommented:
try


="javascript:void(window.open('../arparentnotes/webform1.aspx?ctrlnum=" & Server.HTMLEncode(Fields!Expr2.Value) & "','_blank'))"
 
or 
check the field property, does it has 
htmlencode then set it to "true"
 
if this doesnt work then in SQL while retrieving data at that time only you can write some function which encode the data

Open in new window

0
jay-areAuthor Commented:
The Hyperlink expression for the textbox textbox11 contains an error: [BC30451] Name 'Server' is not declared.

So that doesn't work either since it won't recognize Server.HTMLEncode().  How do I do this on the sql side?
0
ASPSQLServerCOMCommented:
other way is like
create one function in SQL which will do same functionality as HTML

example - (but this does not have the ready made function, I think you have to write or search )
http://support.microsoft.com/kb/246069

then in your select statement use this function to return the encoded data
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jay-areAuthor Commented:
I'm still working on this one but having trouble.  Will post again later if I can't get it to work.  Thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.