views:

1158

answers:

3

Is there a maximum length when using window.returnValue (variant) in a modal?

I am calling a modal window using showModalDialog() and returning a comma delimited string. After selecting a group of users, I am putting them into a stringbuilder to display in a literal.

Dim strReturn As New StringBuilder
strReturn.Append("<script type=""text/javascript"">window.returnValue='")
Dim strUsers As New StringBuilder
For Each dtRow As DataRow In GetSelectedUserTable.Rows
    If strUsers.ToString.Length > 0 Then
        strUsers.Append(",")
    End If
    strUsers.Append(dtRow("UserID"))
Next
strReturn.Append(strUsers.ToString)
strReturn.Append("';window.close();</script>")
litReturnJavascript.Text = strReturn.ToString

So would there be a limit on how many characters can be added to the window.returnValue?

+1  A: 

First, in what browser are you having problems? window.returnValue isn't even supported in Firefox, maybe not even other browsers.

Second, have you looked the value of strUsers after building it to make sure there are no single or double quotes in that string?

I would guess that the maximum size/length of that property would be determined more by your system's memory than anything else.


EDIT: Maybe you should look at using window.open() to open a new window and window.opener to set the value on the parent form instead - it is supported by more browsers. Just a suggestion...

Jason Bunting
A: 

My users have to use IE6 (not my call), and the modal is already wired for IE so that is why I am using showModalDialog.

strUsers will always be a comma delimited list of integers

E.G.: 384834,583882,343993,391823,302103
Steve Wright
A: 

JasonBunting has a good suggestion. You can have the modal dialog update the parent before you close it. This way you can pass objects back and forth between your windows without worrying about the limitation of the return value. For example, you could have a hidden field on the parent that you update with your return values.

David Robbins