javascript popup window and multiple parameters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DaveyP

    javascript popup window and multiple parameters

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



    asp code:

    <asp:TemplateFi eld

    HeaderText="Let ter code"

    ItemStyle-HorizontalAlign =Center>

    <ItemTemplate >
    <asp:hyperlin k

    ID=letter_code

    runat=server

    NavigateUrl=<
    %#String.Format ("javascript:vo id(OpenPopupWin dow('letter_res ponse_detail.as px?
    letter_code={0} ','width=900,he ight=450,top=47 5,left=300,scro llbars=yes,resi zable=yes'));", Eval("letter_co de"))
    %>>

    <%#Container.Da taItem("letter_ code")%>
    </asp:HyperLink>

    </ItemTemplate>

    </asp:TemplateFie ld>

    /asp code



    Code for the routine is :



    <script language="javas cript">

    function OpenPopupWindow (target_url,win _options)
    {

    Window.open(tar get_url,null,wi n_options)retur n 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?=

    #2
    Re: javascript popup window and multiple parameters

    DaveyP wrote:
    I've got a gridview with a template column calling a javascript
    "win.open" routine (see below).
    >
    asp code:
    >
    <asp:TemplateFi eld
    HeaderText="Let ter code"
    ItemStyle-HorizontalAlign =Center>
    <ItemTemplate >
    <asp:hyperlin k
    ID=letter_code
    runat=server
    NavigateUrl=<
    %#String.Format ("javascript:vo id(OpenPopupWin dow('letter_res ponse_detail.as px?
    letter_code={0} ','width=900,he ight=450,top=47 5,left=300,scro llbars=yes,resi zable=yes'));", Eval("letter_co de"))
    %>>
    <%#Container.Da taItem("letter_ code")%>
    </asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateFie ld>
    >
    /asp code
    >
    >
    Code for the routine is :
    >
    <script language="javas cript">
    >
    function OpenPopupWindow (target_url,win _options)
    {
    >
    Window.open(tar get_url,null,wi n_options)retur n 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.

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    Working...