DataList [Edit Item Template] LinkButton call Javascript to open new window

Discussion in 'ASP .Net' started by Nevyn Twyll, Aug 16, 2003.

  1. Nevyn Twyll

    Nevyn Twyll Guest

    I have a DataList; in the DataList's [EditItemTemplate], I have a LinkButton
    and a few listboxes.
    When the LinkButton is pressed, I need to get the ID of the selected item in
    one of the Listbox controls.
    Then I want to launch another web page in a seperate window, using that ID.

    In the header of the web page, I have a javascript function
    LaunchMyWindow(iID) that launches that window.

    For a normal LinkButton Control, I could just use
    LinkButton.Attributes.Add() in the code-behind Page.OnInit() to add a call
    to the javascript function. But:
    1) I can't access the LinkButton from OnInit(), because it's inside the
    DataList, and
    2) (more importantly) the LinkButton needs to get an ID out of the listbox.

    I know I could use the ItemCommand on the DataList in the code-behind to
    Redirect to the page I want to go to, but I need it to be a popup....

    Help?
     
    Nevyn Twyll, Aug 16, 2003
    #1
    1. Advertising

  2. Nevyn,

    On the page's post back when the link button is clicked get the id you need.
    Then instead of doing a response.redirect (which, as you've stated wouldn't
    be a popup) attach your popup script to the body tag of the page.

    You can do this by making the body tag into a server control. Then you can
    add the javascript to open your window to the body tag's onload event.

    I have an example of how to make the body tag into a server control on my
    website, www.aboutfortunate.com. Just search the code library for: "use body
    tag as server control" or something similar.

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Nevyn Twyll" <> wrote in message
    news:%...
    > I have a DataList; in the DataList's [EditItemTemplate], I have a

    LinkButton
    > and a few listboxes.
    > When the LinkButton is pressed, I need to get the ID of the selected item

    in
    > one of the Listbox controls.
    > Then I want to launch another web page in a seperate window, using that

    ID.
    >
    > In the header of the web page, I have a javascript function
    > LaunchMyWindow(iID) that launches that window.
    >
    > For a normal LinkButton Control, I could just use
    > LinkButton.Attributes.Add() in the code-behind Page.OnInit() to add a call
    > to the javascript function. But:
    > 1) I can't access the LinkButton from OnInit(), because it's inside the
    > DataList, and
    > 2) (more importantly) the LinkButton needs to get an ID out of the

    listbox.
    >
    > I know I could use the ItemCommand on the DataList in the code-behind to
    > Redirect to the page I want to go to, but I need it to be a popup....
    >
    > Help?
    >
    >
     
    S. Justin Gengo, Aug 16, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wee Bubba
    Replies:
    0
    Views:
    540
    Wee Bubba
    May 24, 2004
  2. =?Utf-8?B?SnVsZXNfQW5pbWU=?=

    Open New Window from DataList Item...

    =?Utf-8?B?SnVsZXNfQW5pbWU=?=, Nov 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,090
    =?Utf-8?B?SnVsZXNfQW5pbWU=?=
    Nov 22, 2005
  3. Nevyn Twyll
    Replies:
    1
    Views:
    237
    S. Justin Gengo
    Aug 16, 2003
  4. Ann
    Replies:
    0
    Views:
    164
  5. PC HUA
    Replies:
    2
    Views:
    436
    PC HUA
    May 19, 2004
Loading...

Share This Page