473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HtmlImage

I have been trying to use an HtmlImage inside a Panel in an ASP.NET
application. I discovered that text dynamically generated by the client
persists inside the Panel across round trips but HtmlImage controls do not.
However the ListItem controls I used dynamically generated by the server and
added to a drop-down list box do persist across round trips automatically.
I also found that some of the HtmlImage control can be made to persist by
placing it in the Session. However, this is only true of parts of the
control. The Src attribute would not Stay defined in the Session object
across round trips. The ID an several other attributes were maintained in
the Session.

After spending all this time finding out what works and what appears not to
I am unable to resist the temptation of actually using the HtmlImage control
unaware of other surprises that may be in store. Considering what little I
have been able to get it to do I would have saved much time writing my own
control.

Is there any rhyme or reason to the behavior of these HtmlControls? Is there
a reason for this behavior or do they just have bugs?

Signed,
Confused and Bewildered
Dec 21 '05 #1
2 1832
A Server Control is a class that renders HTML. It resides on the server, and
is not persisted across PostBacks. What *is* persisted is (in many cases)
the HTML it renders. It all depends on how the Server Control was created to
use ViewState for persistence. Controls that are inside other Controls are
not HTML, but Server Controls themselves, classes on the server. If you add
one to another Control, it is not persisted, because it isn't part of that
Control's HTML. List Items are not really persisted across PostBacks. They
render <option> tags in an HTML <select> object (the ListBox creates this),
and the options, which are part of the HTML rendered by the server-side
Controls, is persisted by design.

Everything in an ASPX page is destroyed when the Page is sent back to the
client, because HTTP is stateless. There is a complex mechanism that
re-creates it after a PostBack, by looking at the hidden ViewState form
field, and the values of the form fields returned with the POST Request.
Again, only that HTML data that belongs to a Control, and is persisted in
ViewState, is re-created when the Page Posts Back.

If you understand how ASP.Net works, you are less likely to be surprised,
and know what to do, and when. Controls that are dynamically added to a Page
by code during one Request must also be dynamically added during subsequent
Requests, or they will not be there. The Page template contains code that
indicates what Controls are *always* present in the Page; anything else is
purely under your control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"David" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:Psiqf.71706$WH.8975@dukeread01...
I have been trying to use an HtmlImage inside a Panel in an ASP.NET
application. I discovered that text dynamically generated by the client
persists inside the Panel across round trips but HtmlImage controls do not.
However the ListItem controls I used dynamically generated by the server
and added to a drop-down list box do persist across round trips
automatically. I also found that some of the HtmlImage control can be made
to persist by placing it in the Session. However, this is only true of
parts of the control. The Src attribute would not Stay defined in the
Session object across round trips. The ID an several other attributes were
maintained in the Session.

After spending all this time finding out what works and what appears not
to I am unable to resist the temptation of actually using the HtmlImage
control unaware of other surprises that may be in store. Considering what
little I have been able to get it to do I would have saved much time
writing my own control.

Is there any rhyme or reason to the behavior of these HtmlControls? Is
there a reason for this behavior or do they just have bugs?

Signed,
Confused and Bewildered

Dec 21 '05 #2
Thank you very much for the reply. I have one clarification and one
question.

Everything in an ASPX page is destroyed when the Page is sent back to the
client, because HTTP is stateless. There is a complex mechanism that
re-creates it after a PostBack, by looking at the hidden ViewState form
field, and the values of the form fields returned with the POST Request.
Again, only that HTML data that belongs to a Control, and is persisted in
ViewState, is re-created when the Page Posts Back.
When the HtmlImage control is placed into the Session object the ID, the
Style and the client side event handlers persist across round trips. The
Src attribute does not. It seems strange that there should be just one
exception. I suspect there is a problem with the code that generates the
"ViewState", that is, a BUG. I had to write the code myself to store that
value in a hidden while the server lets the client take over.

If you understand how ASP.Net works, you are less likely to be surprised,
and know what to do, and when. Controls that are dynamically added to a
Page by code during one Request must also be dynamically added during
subsequent Requests, or they will not be there. The Page template contains
code that indicates what Controls are *always* present in the Page;
anything else is purely under your control.


Page template? I'll have to look into that. Thank you.

Dec 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: CodeRazor | last post by:
I am building my html page in .net. After i click a button, i want an outline/border to appear around my button. I have found the HtmlInputImage.Border property and although it prints out...
5
by: David Elliott | last post by:
I need a control on a Web Page that can accept an HTML Document and will display it. Any help would be appreciated. Thanks, Dave Here is what I was trying...
0
by: Alberto | last post by:
Hi, I am having a strange problem when using the HTMLIMAGE control. I have a aspx page that contains the htmlimage control (explore.aspx). I generate an <img src=...> tag, with a URL that...
3
by: Sophos | last post by:
Hi, I have a basic aspx page, in the Page_Init procedure I have a server.execute of another aspx page that adds some html code to my first page. However it also adds a control (an htmlimage),...
0
by: J | last post by:
Hi all, I've got a problem with a HtmlImage I'm adding to a TableCell object. What I'm trying to do is add an attribute to the image like this; oHtmlImage.Src =...
0
by: tparks69 | last post by:
All I want to do is change the border of the first img control in my html to 0. The other images I want to have border=1. I have an event on my datalist that calls the following code: ...
13
by: John Rivers | last post by:
Here is an example of what I am talking about: asp.net takes what is a very simple, powerful and flexible concept, http request/response with html for presentation and turns it into a...
3
by: RKT | last post by:
(CSharp, NET2.0) Is there any way to EITHER: 1. Programmatically add a server onclick() event hander to the 'HtmlImage' HtmlControl control? OR 2. Programmatically preempt a 'Image'...
0
by: rn5a | last post by:
A Web Form has 2 DataGrids. At any given time, only one of the DataGrids will be visible to a user. Both the DataGrids also have images (<img src../>) in the headers. The 1st DataGrid has 7 columns...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.