Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

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!
0
jay-are
Asked:
jay-are
  • 11
  • 10
  • +2
1 Solution
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 10
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now