473,231 Members | 1,826 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,231 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 1827
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.