This is a migrated thread and some comments may be shown as answers.

Opening Radwindow with Javascript and passing multiple querystring parameters to target page

1 Answer 412 Views
Window
This is a migrated thread and some comments may be shown as answers.
KevinMc
Top achievements
Rank 1
KevinMc asked on 20 May 2008, 09:22 PM
I am sure i just have a syntax error but i have been playing with this for over an hour and still can't figure it out. I have a page that opens a rad window from a javascript function and passes 2 querystring arguments as parameters. 

Here is the javascript to open the window:
<script type="text/javascript">  
 
        function openEditorWindow(forumID, typeofPost)  
        {  
            var oReadingWnd = radopen("PostEditor.aspx?ForumID=" + forumID + "&PostType=" + typeofPost);  
            oReadingWnd.Center();  
        }  
    </script> 

Here is the code-behind to set the buttons onclick event.
 lnkNewThread1.Attributes.Add("onclick""javascript:openEditorWindow('" + this.Request.QueryString["ForumID"] + ", " + PostType.NewThread.ToString() + "')"); 

Here is the button that is supposed to launch the window.
<asp:HyperLink runat="server" ID="lnkNewThread1" NavigateUrl="#" ImageUrl="~/Images/forum_new_thread.png"   
                        Text="Start New Topic"/> 

When i load the page and click the link i get an exception that querystring format is invalid. When i inspect the querystring the javascript function is appending to the radwindow open call is looks like this:

?ForumID=1%2cNewThread&PostType=undefined

Obviously the javascript function is treating the parameters passed from the onclick event as a single string but i have no idea at this point how to format that onclick so that the javascript function grabs both variables. I found a million examples passing just a single parameter from onclick to a javascript function but can't seem to find any that pass two or more.

1 Answer, 1 is accepted

Sort by
0
KevinMc
Top achievements
Rank 1
answered on 21 May 2008, 12:29 AM
Well as usual waling away for a few hours clears the head. The attributes.add in the code-behind needed to add quotes around each parameter being passed instead of arounf the whole string being passed so it should look like:

lnkNewThread1.Attributes.Add("onclick""javascript:openEditorWindow('" + this.Request.QueryString["ForumID"] + "', '" + PostType.NewThread.ToString() + "')"); 
Tags
Window
Asked by
KevinMc
Top achievements
Rank 1
Answers by
KevinMc
Top achievements
Rank 1
Share this question
or