javascript popup window and multiple parameters

D

DaveyP

I've got a gridview with a template column calling a javascript
"win.open" routine (see below).



asp code:

<asp:TemplateField

HeaderText="Letter code"

ItemStyle-HorizontalAlign=Center>

<ItemTemplate>
<asp:hyperlink

ID=letter_code

runat=server

NavigateUrl=<
%#String.Format("javascript:void(OpenPopupWindow('letter_response_detail.aspx?
letter_code={0}','width=900,height=450,top=475,left=300,scrollbars=yes,resizable=yes'));",Eval("letter_code"))
%>>

<%#Container.DataItem("letter_code")%>
</asp:HyperLink>

</ItemTemplate>

</asp:TemplateField>

/asp code



Code for the routine is :



<script language="javascript">

function OpenPopupWindow(target_url,win_options)
{

Window.open(target_url,null,win_options)return false
}



</script>



This works fine. The problem that I have, is that I now need to call
the popup with two extra parameters which are taken from 2
dropdownlists elsewhere on the form.

Suggestions as to how I do this?



Cheers
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

DaveyP said:
I've got a gridview with a template column calling a javascript
"win.open" routine (see below).

asp code:

<asp:TemplateField
HeaderText="Letter code"
ItemStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:hyperlink
ID=letter_code
runat=server
NavigateUrl=<
%#String.Format("javascript:void(OpenPopupWindow('letter_response_detail.aspx?
letter_code={0}','width=900,height=450,top=475,left=300,scrollbars=yes,resizable=yes'));",Eval("letter_code"))
%>>
<%#Container.DataItem("letter_code")%>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

/asp code


Code for the routine is :

<script language="javascript">

function OpenPopupWindow(target_url,win_options)
{

Window.open(target_url,null,win_options)return false

There is no Window object in Javascript, it's named window. Javascript
is case sensetive.

Don't use null as window name. Use '_blank' if you want to open a new
window.

You have forgotten the semicolon between the statemenets.
}

</script>


This works fine. The problem that I have, is that I now need to call
the popup with two extra parameters which are taken from 2
dropdownlists elsewhere on the form.

Suggestions as to how I do this?

Do you want to take the values at the time of creating the page, or when
the user clicks the link?

For the first, you would add parameters in the String.Format, and append
the url in the format string with "&{1}&{2}".

For the second, you would add the values in the javascript. Perhaps
creating a new function if you don't want to change the OpenPopupWindow
function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top