Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

image  urls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jaez - 08 Oct 2007 15:02 GMT
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
Mark Rae [MVP] - 08 Oct 2007 15:11 GMT
> 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
[quoted text clipped - 8 lines]
>
> <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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Eliyahu Goldin - 08 Oct 2007 15:20 GMT
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.

Signature

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

> 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
[quoted text clipped - 10 lines]
>
> jaez
Jaez - 08 Oct 2007 19:17 GMT
Thanks folks

works fine

> You can keep your syntax if you wish, just add runat=server and call
> DataBind method for the page.
[quoted text clipped - 19 lines]
>>
>> jaez
Mike - 09 Oct 2007 19:57 GMT
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

> 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
[quoted text clipped - 10 lines]
>
> jaez

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.