Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

open a new window with a dynamic url

Posted on 2005-05-02
4
Medium Priority
?
360 Views
Last Modified: 2012-08-14
hello,

someone please help me asap.  i need to finish this project.  i am making a datalist where it brings in a bunch of images which are then clickable. when an image is clicked, i want a new small window to open with the bigger image.  i want the link to dynamically carry the id of the row where the image is stored.  for example:

ID: 12
SmallImage: abc.jpg
BigImage: abc_big.jpg

when abc.jpg is clicked, it opens "press_detail.aspx?ID=12".  press_detail.aspx is a web form where it displays the big image and some additional information.  i know that the following code is for html:

<A onclick="MyWindow=window.open('Press/LV-0405.aspx','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=600,height=650,left=10,top=10'); return false;" href="#">

How can I do this dynamically behind the code just as the following:

aspx file
---------------------
<asp:ImageButton ID="EnlargedPressImage" Runat="server"></asp:ImageButton>

aspx.vb file
----------------------
???????????
WHAT DO I DO HERE?


Some, please guide me in the right direction.  maybe im even going to complete wrong way.

thanks a million.
0
Comment
Question by:attipa
4 Comments
 
LVL 33

Assisted Solution

by:raterus
raterus earned 1000 total points
ID: 13913921
Image Button's postback the form, that isn't what you are doing here so you do not need the imagebutton here.  All you really have to do is make the <a> tag runat="server" the <a> tag so you can dynamically set the link, like so

<A id="myPicture" runat="server" href="#">

...

myPicture.Attributes.add("onclick", "window.open(...)")
0
 

Author Comment

by:attipa
ID: 13913955
ok...that is a lot of info...thanks...however one more question.

when you say.....


myPicture.Attributes.add("onclick", "window.open(...)")  

window.open('Press/LV-0405.aspx'.......) is the example i have up there.  how can i make it dynamic so i get the following......

window.open('Press/press_detail.aspx?ID='........)  <---- HOW CAN I ADD THE ID NUMBER DYNAMICALLY HERE?????  PLEASE WRITE OUT THE FULL CODE FOR THIS...I REALLY APPRECIATE IT.
0
 
LVL 24

Assisted Solution

by:Jeff Certain
Jeff Certain earned 800 total points
ID: 13914164
myPicture.Attributes.add("onclick", "window.open('Press/press_detail.aspx?ID=" & thisID & "'))")  

1. Replace thisID with the variable containing the ID you're interested.
2. The about code assumes your ID is an integer or other number.
0
 
LVL 16

Accepted Solution

by:
MikeMCSD earned 200 total points
ID: 13914699
Put this code on the page where your datalist is:

<script language="JavaScript">
function oWin(iPath)  {
  newWin = window.open("press_detail.aspx?path=" + iPath,
  "winOne","height=530,width=580,status=yes,toolbar=no,menubar=no,location=no,top=0,left=0,resizable=yes,scrollbars=yes");}
</script>

<asp:datalist  . . . .>
<ItemTemplate>
<img border="1" src='<%# DataBinder.Eval(Container.DataItem, "small_Image")) %>'
onClick="oWin('<%# DataBinder.Eval(Container.DataItem, "large_Image")) %>');" style="cursor: pointer;" />
........
If you are reading the values from a database into your datalist, this will work.



0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question