Images

  • Thread starter Thread starter Charles A. Lackman
  • Start date Start date
C

Charles A. Lackman

Hello,

I am placing an image on a page using the following code:

Response.Write("<img src=""images/MyImage.jpg">")

This works ok, but it places the image at the top of the page. How do I
make the image show at the bottom of the page or at a particular spot.

Thanks,

Chuck
 
Let me guess. You're an old ASP developer, right?

ASP is procedural. ASP.Net is object-oriented. Response.Write() is a method
which you should almost NEVER call in ASP.Net. The way ASP works is, the
script is parsed from the top to the bottom. Everything that happens happens
in sequential order. Therefore, using Response.Write() in ASP puts whatever
you write wherever you put Response.Write(). In ASP.Net, things are not so
simple. You have to think in object-oriented terms. A page is a class. It
contains Controls. The Controls are positioned by any of several ways. They
can appear in the Template where you want them to be, and they can obey the
rules of HTML. You can use CSS to absolutely position them. But what you
have tokeep in mind is that the page is not processed sequentially.
Everything in it is a Control. Even pure text is converted to a Control at
run-time. So, if you want an image in a page, use a Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Because ASP.NET compiles your page it will always write out response streams
at the very beginning of the page, on the contrary in asp, code was
interpreted by a scripting engine so it would go from top to bottom and
write out your html.

Therefore, you now have to use web controls to tell asp.net where you want
your image to appear. You can add a placeholder control to your aspx page
and dynamically add your image contol to its control collection from your
codebehind page. To get a full understanding of what asp.net brings to the
table. You can watch this webcast series
http://www.microsoft.com/seminar/events/series/essentialaspnet.mspx#On-Demand Webcasts

The presenter really breaks things down for the absolute beginner.
 
Place an image control on the page in the desired location.
The from your code behind, use a line like this:

MyImageControl.ImageURL="images/MyImage.jpg"
 
You can also use a placeholder that "Tampa.NET Koder" mentioned.

You put the following server tag in the desired location within the
html section:
<asp:PlaceHolder runat="server" id="LCHolder" /> (LCHolder short for
Lable Control Holder)

and then in the page_load sub you write:
For i = 0 to 10
Dim lb as New Label()
lb.ID = "lb"& i
lb.text = "Your url here, or a number, or whatever... this way you
could iterate through an array of urls or whatever, and they appear
wherever the placeholder is"
Next
------------------
There are many ways to do what you want, but I guess that can be said
for anything.

Also, he could have roots in vbscript or something similiar, thinking
that asp.net behaves like a scripting engine. I remember when I thought
that at first when I started asp.net.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top