473,809 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BUG: Setting Server Control's InnerHtml forces Constructore to be called.

While creating a shopping cart application I noticed a strange bug which resulted in the Constructor and everything being called twice. I was using Inherited classes ClassShowProduc ts inherited TemplatePage which inherited System.Web.UI.P age which I thought was the problem so I spent all day recoding everything so that ClassShowProduc ts was inherited from System.Web.UI.P age. Then I found out that it still happend.
I then quickly narrowed it down to one line of code in Page_Load(

i have a server control <td id="tdMainConte nt" runat="server"> and in my Page_Load i go
tdMainContent.I nnerHtml = render_MainBody (); // returns a massive string

if i go string MainContent = render_MainBody (); it works fine
however the minute I try setting tdMainContent.I nnerHtml it borks and basically when Page_Load ends the class constructor is called and goes through everything again, Class Constructor, OnInit, InitializeCompo nent, Page_Load etc.

The Length of the string is 4927 bytes and is Valid HTML Content.
After doing some tdMainBodyConte nt.InnerHtml = string('c', randomlenghs);
it does not appear to be "content length" related I am thinking it may be related to complexity of the structure of the HTML. I have checked the HTML and it is W3C Valid and since it is generated by XML/XSLT i know that there will not be any missing/open tags . I am at a loss
Nov 18 '05
10 1787
Okay. That sound's reasonable. So hopefuly if it comes back i should just
look for an <img tag without any empty src specified. I wish i would have
seent he pattern before. Thanks for everything

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:UM******** ********@cpmsft ngxa06.phx.gbl. ..
Hi,
Thanks for your followup. I've done some further tests on different
machines and finally found out the root cause of this issue. The problem
is
caused by the "Default Documents" set in the VirtualDirctory , the by
default an IIS Virtual Directory's Default Documents are "default.ht m",
"index.htm" , "default.as p", "iisstart.a sp". And maybe has the
"default.as px" . The "Default Documents" means when you didn't specify a
certain file name in a url , such as
"http://localhost/WebApplication5/" then, the IIS will search in the
default documents, if any one find then redirect to that certain file. And
also if you used some certain relative path url to refer a no file
specified url such as
<img src=""/> (if this image tag is in a page in the virutal directory's
root folder) then, the default document will also be called.

And from your code in the string you set in the page_load
private void Page_Load(objec t sender, System.EventArg s e)
{
tdMainBodyConte nt.InnerHtml = "......."
}
There contains an "<img src=\"\">", yes? You may have a check, then, that
cause the IIS search for the default documents and you can check the
WebApplication5 's virual directory's Default Document attributes to see
whether the "Default.as px" is in the list, I'm sure it is in that list ,
and that's why the Default.aspx is caused again. So this problem can be
repro event if we hard code a <img src=""> tag in the aspx page. And I've
add one of my repro page named "MyReproPag e" in the modified project I've
attached in this message. Please check it out.

In addition, as for my last reply( I mentioned that I didn't repro this
problem). That's because I firstly test in a machine(WINXP) on which the
IIS by default didn't add the "Default.as px" into the default documents.
However, when I tried testing on a WIN2003 server machine,where by default
"Default.as px" is added in the virual directory's default documents, then
I
was managed to repro this. Seems a bit lucky:).

Anyway, please check out the above results. If you found any difference
from my result or have any further questions, please feel free to post
here.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #11

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

Similar topics

4
2668
by: Jim Mitchell | last post by:
I have a web page that I show using show ModalDialog. The web page takes about 6 seconds to load. No matter what I try, I can not get the cursor to show a "WAIT" until the page is loaded in the showModalDialog Window, I have even tried having a hidden panel in the calling web site and trying to turn it off from the target web site using...
4
2545
by: Howard Jess | last post by:
In Opera 8.01 (Linux; Build 1204) and in Opera 7.54 (Windows XP; Build 3865), my form disappears from the HTML markup (below). To summarize: 1) In a <script> block in the <head> I create a form element (part of object/feature/bug detection). 2) There's a <form> element defined in the <body>, with the id 'theForm'. 3) The onload function tries to access that form, and also counts the total number of forms in the document. It fails to...
9
2155
by: Just D. | last post by:
All, Did anybody see this strange effect? The web application is written in C#, ASP.NET, SQL, T-SQL, etc. A pretty usual stuff, complicated enough, but works fine until... Here is a question. I don't see any problem if I start this app on my local computer against my local IE both in debug or release modes. If I upload the same app to my corporate server where it works under HTTPS here are a few possible ways.
3
4442
by: Diego F. | last post by:
Hello. I'm trying to call a function that prints the content of a div element. I had that javascript code working, but now I must put that code in the server side, as it is called from another component. The problem is that it can't find the div control. Don't know why. I paste the code here: That's in the aspx.vb file: Response.Write("<script>")
5
2644
by: Dave A | last post by:
I am writing an ASP.NET tool that will allow the client to create their own online froms. ie the client can add tect boxes, text, drop downs,etc with absolutely no technical skill what so ever. The form can then be deployed to their intranet. The form designer is somewhat WYSIWYG but it contains a heap of 'edit', 'delete' and reordering buttons that are not seen when the form is acutally being used. I would love to have a preview...
3
1938
by: Jon Delano | last post by:
Hi I was wondering if it were possible to somehow stop a page from posting back to the server and running the server side code. I have a datagrid and the first column is basically a button. I have added a javascript function to the button : Dim btnView As LinkButton = e.Item.Cells(0).Controls(0) btnView.Attributes.Add("onclick", "CheckDictationMode();")
6
2532
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you get response from a Confirm() popup window to uncheck all server-side checkboxes placed in a panle of a web user control? I am using ASP.Net 2.0, Thanks. Need info...
20
3013
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is a control. I have 2 files "displayCompanyJobs.aspx" and "displayCompanyOverview.aspx" which are in both the folder "/jobseeker/" and "/employer/". I have a user control "displayCompanyJobs.ascx" that is in my /applicant/
12
2061
by: Juan T. Llibre | last post by:
re: !I found an MSDN document that explains why what I'm trying to do should work Lee, From : http://www.w3.org/TR/REC-xml/ "A special attribute named xml:lang may be inserted in documents to specify the
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.