window.showmodaldialog

  • Thread starter Thread starter Ben Schumacher
  • Start date Start date
B

Ben Schumacher

I keep getting a script error (Expected end of statement) when I try to add
the following attribute to a <asp:Button server control. My vb.net looks as
follows ...

Dim sUrl As String = "../popup/newfolder.aspx"

Dim vArguments As String = "document.all('" & cmdNew.ClientID & "')"

Dim sfeatures As String = String.Empty

Dim s As String = "vbscript:vReturnValue = window.showModalDialog('" & sUrl
& "', " & vArguments & ", '" & sfeatures & "')"

cmdNew.Attributes.Add("OnClick", s)

Any suggestions?
 
Ben Schumacher said:
I keep getting a script error (Expected end of statement) when I try to add
the following attribute to a <asp:Button server control. My vb.net looks
as follows ...

Dim sUrl As String = "../popup/newfolder.aspx"

Dim vArguments As String = "document.all('" & cmdNew.ClientID & "')"

Dim sfeatures As String = String.Empty

Dim s As String = "vbscript:vReturnValue = window.showModalDialog('" &
sUrl & "', " & vArguments & ", '" & sfeatures & "')"

cmdNew.Attributes.Add("OnClick", s)

Any suggestions?

It looks as though you are using the single quote ' for all of your string
delimiters. The problem you are running into is that your vArguments is
set up using the ' as its delimiter so you are declaring it like this:

vArguments as string = "doucment.all('somevalue')"

Notice that <somevalue> is enclosed with ' delimiters.

If I put that into the s as String Line it would be like this:

Dim s as String =
"vbscript:vReturnValue=window.showModalDialog('surl','document.all('somevalue')','sfeatures')

In debug you should see it cut off here:
vbscript:vReturnValue=window.showModalDialog('surl','document.all(' --
When it hits this ' it thinks the string is done. To Fix this problem
enclose the vArguemtns with " double quotes. Like this:

Dim vArguments as String = "document.all(""" & cmdNew.ClientID & """)"

Good luck

jjardine
 
Back
Top