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

N

Nevyn Twyll

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

S. Justin Gengo

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
 

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

Top