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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Added serverside script to a clientscriptBlock

Status
Not open for further replies.

SpeedBWild

Programmer
Apr 29, 2004
117
0
0
US
I am trying to add a severside variable to the client script block. All of this code works except the <%=fileName%> variable is not passed in. Do I need to do something special?

Const SCRIPT_KEY As String = "PopUpWindow"

Const SCRIPT As String = "<script language=""javascript""> " + vbCr + _
"<!-- " + vbCr + _
"var features= 'scrollbars=yes,toolbars=no,status=yes,height=700,width=575,top=0'; " + vbCr + _
"window.open('ManageDetail.aspx?fileName=<%=fileName%>', 'Detail', features);" + vbCr + _
"// --> </script> "

If Not (Page.IsClientScriptBlockRegistered(SCRIPT_KEY)) Then
Page.RegisterClientScriptBlock(SCRIPT_KEY, SCRIPT)
End If
 
a small change:
Const SCRIPT As String = "<script language=""javascript""> " + vbCr + _
"<!-- " + vbCr + _
"var features= 'scrollbars=yes,toolbars=no,status=yes,height=700,width=575,top=0'; " + vbCr + _
"window.open('ManageDetail.aspx?fileName="+fileName+"', 'Detail', features);" + vbCr + _
"// --> </script> "


Known is handfull, Unknown is worldfull
 
I have all ready tried that it says "constant expression is required". I also tried "window.open('ManageDetail.aspx?fileName="+<%=fileName%>+"', 'Detail', features);" + vbCr + _

with no luck.

Any other ideas?
 
>>I have all ready tried that it says "constant expression is required".

Which line is it pointing to???

Known is handfull, Unknown is worldfull
 
You are trying to declare a constant variable that isn't constant because you are including a variable in it!

Try using a Private variable and use ampersands (&) to concatenate your strings not a plus sign. e.g.
Code:
Private SCRIPT As String = "<script language=""javascript""> " & vbCr & _
            "<!-- " & vbCr & _
            "var features= 'scrollbars=yes,toolbars=no,status=yes,height=700,width=575,top=0'; " & vbCr & _
            "window.open('ManageDetail.aspx?fileName=" & fileName & "', 'Detail', features);" & vbCr & _
             "// --> </script> "


____________________________________________________________

Need help finding an answer?

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

 
I tried that I sitll get "constant expression is required". I get the line under fileName and it doesn't compile.
 
Where and how have you declared fileName? Also, I should have said to use Dim rather than Private if you are declaring and assigning the SCRIPT variable from within a sub/function.


____________________________________________________________

Need help finding an answer?

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

 
File Name is being pass into the sub. Then within the function I add the javascipt block. I thought I could do <%=fileName%>. But that doesn't seem to work. I am wondering if there is any special syntax that I need to use. I noticed that when I have a function with a script block I had to use double "{". If there is any special syntax I just can't seem to find any documentation on it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top