open a new window with a dynamic url

Posted on 2005-05-02
Last Modified: 2012-08-14

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="'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

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

thanks a million.
Question by:attipa
    LVL 33

    Assisted Solution

    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", "")

    Author Comment

    ok...that is a lot of info...thanks...however one more question.

    when you say.....

    myPicture.Attributes.add("onclick", "")'Press/LV-0405.aspx'.......) is the example i have up there.  how can i make it dynamic so i get the following......'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.
    LVL 24

    Assisted Solution

    by:Jeff Certain
    myPicture.Attributes.add("onclick", "'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.
    LVL 16

    Accepted Solution

    Put this code on the page where your datalist is:

    <script language="JavaScript">
    function oWin(iPath)  {
      newWin ="press_detail.aspx?path=" + iPath,

    <asp:datalist  . . . .>
    <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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now