HighTechTalks DotNet Forums  

image urls

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss image urls in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jaez
 
Posts: n/a

Default image urls - 10-08-2007 , 10:02 AM








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



Reply With Quote
  #2  
Old   
Mark Rae [MVP]
 
Posts: n/a

Default Re: image urls - 10-08-2007 , 10:11 AM






"Jaez" <jaezms (AT) ntlworld (DOT) com> wrote


Quote:
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



Reply With Quote
  #3  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: image urls - 10-08-2007 , 10:20 AM



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" <jaezms (AT) ntlworld (DOT) com> wrote

Quote:

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





Reply With Quote
  #4  
Old   
Jaez
 
Posts: n/a

Default Re: image urls - 10-08-2007 , 02:17 PM



Thanks folks

works fine




"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN (AT) mMvVpPsS (DOT) org> wrote in
message news:OapvzZbCIHA.5980 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Quote:
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" <jaezms (AT) ntlworld (DOT) com> wrote in message
news:HLqOi.780$ah6.751 (AT) newsfe4-win (DOT) ntli.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
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







Reply With Quote
  #5  
Old   
Mike
 
Posts: n/a

Default Re: image urls - 10-09-2007 , 02:57 PM



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" <jaezms (AT) ntlworld (DOT) com> wrote

Quote:

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



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.