image urls

Discussion in 'ASP .Net' started by Jaez, Oct 8, 2007.

  1. Jaez

    Jaez Guest

    On an aspx page I am trying to place an image which can be clicked on to
    download a file. Neither the image or the url of the doc are known until
    runtime

    Textbox1.text contains the url of a word document and textbox2.text contains
    the url of a png graphic

    Please can someone help me with the syntax as this does not work

    <a href='<%# textbox1.text %>'>

    <img src='<%# textbox2.text %>' style="width: 60px; height: 60px" /></a>



    jaez
    Jaez, Oct 8, 2007
    #1
    1. Advertising

  2. "Jaez" <> wrote in message
    news:HLqOi.780$...

    > On an aspx page I am trying to place an image which can be clicked on to
    > download a file. Neither the image or the url of the doc are known until
    > runtime
    >
    > Textbox1.text contains the url of a word document and textbox2.text
    > contains the url of a png graphic
    >
    > Please can someone help me with the syntax as this does not work
    >
    > <a href='<%# textbox1.text %>'>
    >
    > <img src='<%# textbox2.text %>' style="width: 60px; height: 60px" /></a>



    How are you populating the page...?

    <%# is databinding syntax - if you just want to refer to the text in the
    textbox, try:

    <%=textbox1.txt%>

    However, depending on how you are fetching / populating the initial data, it
    may not be available when the control is rendered...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Oct 8, 2007
    #2
    1. Advertising

  3. You can keep your syntax if you wish, just add runat=server and call
    DataBind method for the page.

    Or you can use <%= syntax:
    <a href='<%= textbox1.text %>'>

    Or you can use server controls HyperLink and Image and set their attributes
    programmatically.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Jaez" <> wrote in message
    news:HLqOi.780$...
    >
    >
    > On an aspx page I am trying to place an image which can be clicked on to
    > download a file. Neither the image or the url of the doc are known until
    > runtime
    >
    > Textbox1.text contains the url of a word document and textbox2.text
    > contains the url of a png graphic
    >
    > Please can someone help me with the syntax as this does not work
    >
    > <a href='<%# textbox1.text %>'>
    >
    > <img src='<%# textbox2.text %>' style="width: 60px; height: 60px" /></a>
    >
    >
    >
    > jaez
    >
    >
    Eliyahu Goldin, Oct 8, 2007
    #3
  4. Jaez

    Jaez Guest

    Thanks folks

    works fine




    "Eliyahu Goldin" <> wrote in
    message news:...
    > You can keep your syntax if you wish, just add runat=server and call
    > DataBind method for the page.
    >
    > Or you can use <%= syntax:
    > <a href='<%= textbox1.text %>'>
    >
    > Or you can use server controls HyperLink and Image and set their
    > attributes programmatically.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Jaez" <> wrote in message
    > news:HLqOi.780$...
    >>
    >>
    >> On an aspx page I am trying to place an image which can be clicked on to
    >> download a file. Neither the image or the url of the doc are known until
    >> runtime
    >>
    >> Textbox1.text contains the url of a word document and textbox2.text
    >> contains the url of a png graphic
    >>
    >> Please can someone help me with the syntax as this does not work
    >>
    >> <a href='<%# textbox1.text %>'>
    >>
    >> <img src='<%# textbox2.text %>' style="width: 60px; height: 60px" /></a>
    >>
    >>
    >>
    >> jaez
    >>
    >>

    >
    >
    Jaez, Oct 8, 2007
    #4
  5. Jaez

    Mike Guest

    why would you use a textbox as an image?

    why not just use the <img> tag?

    I'm doing something like this to populate an image based on what is returned from the db.

    public string GetDocImage(object docName)
    {
    string strImg;
    if(docName== DBNull.Value)
    {
    strImg = "~/images/empty.gif";
    }
    else
    {
    strImg = "~/images/Docname" + docName+ ".gif";
    }
    return strImg;
    }

    and in the HTML, I do this:

    <asp:Image ID="imgDoc" runat="server" AlternateText='<%# Eval("DocName%>'
    ImageUrl='<%# GetDocImage(Eval("docName")) %>' />

    this returns the docName and the URL for the document to open

    "Jaez" <> wrote in message news:HLqOi.780$...
    >
    >
    > On an aspx page I am trying to place an image which can be clicked on to
    > download a file. Neither the image or the url of the doc are known until
    > runtime
    >
    > Textbox1.text contains the url of a word document and textbox2.text contains
    > the url of a png graphic
    >
    > Please can someone help me with the syntax as this does not work
    >
    > <a href='<%# textbox1.text %>'>
    >
    > <img src='<%# textbox2.text %>' style="width: 60px; height: 60px" /></a>
    >
    >
    >
    > jaez
    >
    >
    Mike, Oct 9, 2007
    #5
    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. Kaidi
    Replies:
    5
    Views:
    454
    Andrew Thompson
    Jan 4, 2004
  2. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    730
    Sriram Srivatsan
    Aug 12, 2008
  3. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,116
    Adam Monsen
    Feb 8, 2009
  4. Fonz
    Replies:
    1
    Views:
    889
    Alexey Smirnov
    Dec 18, 2009
  5. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    272
    Steve T.
    Mar 4, 2004
Loading...

Share This Page