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 10 1785
Hi,
I try it with simple table but I can't reproduce the described behavior.
Can you send me sample code?
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
From the looks of it it appears that the problem ties into me doing
baseUrl.Attribu tes["href"] = Constants.urlDo main
If i comment out that line in my web project and set InnerHtml of the tdMainDody then it works without causing the constructor to be thrown. However this is not reproduceable in a test project that i made that has the exact same code except is all by itself instead of in the massive project i am in.
----- Natty Gur wrote: ----
Hi
I try it with simple table but I can't reproduce the described behavior
Can you send me sample code
Natty Gur[MVP
blog : http://weblogs.asp.net/ngu
Mobile: +972-(0)58-88837
*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it
Hello John,
I couldn't repro it as Natty either. Generally speaking, it is quite hard
to isolate the root cause due without a repro sample. For troubleshooting
this type of issue, you may need use some debugging dump to check call
stack when it is constructed again. Anyway, I am glad to see that you have
found the exact line which cause the problem. If there is any we can do for
you, please feel free to post here.
Thanks.
Best regards,
Yanhong Huang
Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Actually I did not find the root problem. Well I sort of did.
I more found a way to reproduce it every single tim
I have rebuilt over 7 different projects and recoded another one racking my brain trying to figure it out but at least I think i can now reproduce it as i've created 2 new projects and gotten it to exhibit this behavior. I will be posting a sample in just a second.
It seems to be tied to the fact that I have a class named _Default because one of my webpages is Default.asp
For example i did thi
Created a New Web Project -> Copied the Sample code. added a constructor and set a breakpoint on the constructor
Ran the project and it only got called once
So i went (because i already knew this was reproduceable) and added a new page called Default.aspx and set it as the Startup Page. I added the same code and created a constructor and set a breakpoint. Running the project prove that the constructor got called a second time.
Now because my last project was using an Inherited Page Structure this was happening on every single page. So i tested something by setting WebForm1.aspx as the startup page and ran it with breakpoints on both constructors
Webform1.aspx got called and a breakpoint happned in Webform1's Constructor. i hit f5 and then the the next breakpoint popped on Default's Constructor even though Webform1.aspx page was the Startup page.
Is there something I am missing that is special about "Default.as px" ?
What seems to be even funnier is that after one has added a Web Form via Project -> Add New Item -> Webform -> Default.aspx -> and then renamed it appears that this still happens.
I will post sample files under a different ID as I can't attach emails via the web interface
----- jo*****@driver. net wrote: ----
Actually I did not find the root problem. Well I sort of did.
I more found a way to reproduce it every single tim
I have rebuilt over 7 different projects and recoded another one racking my brain trying to figure it out but at least I think i can now reproduce it as i've created 2 new projects and gotten it to exhibit this behavior. I will be posting a sample in just a second.
It seems to be tied to the fact that I have a class named _Default because one of my webpages is Default.asp
For example i did thi
Created a New Web Project -> Copied the Sample code. added a constructor and set a breakpoint on the constructor
Ran the project and it only got called once
So i went (because i already knew this was reproduceable) and added a new page called Default.aspx and set it as the Startup Page. I added the same code and created a constructor and set a breakpoint. Running the project prove that the constructor got called a second time.
Now because my last project was using an Inherited Page Structure this was happening on every single page. So i tested something by setting WebForm1.aspx as the startup page and ran it with breakpoints on both constructors
Webform1.aspx got called and a breakpoint happned in Webform1's Constructor. i hit f5 and then the the next breakpoint popped on Default's Constructor even though Webform1.aspx page was the Startup page.
Is there something I am missing that is special about "Default.as px" ?
Hi,
Thanks for your responses and the sample project you've attached. I've
tested on our application and here is the result I've got:
#I've added break point in all the page classes' constructor(def ault,
WebForm1 and WebForm2) and set them as startup page separatly. However, I
found that each page's aspx has the below code
<body onload="bodyOnL oad();">
but the "bodyOnLoad ()" client script functdion is not found in aspx page so
that everytime after the page's constructor(fir st time), the will throw a
"no Object Reference error" which indicate that the BodyOnLoad function not
defined. Would you please provide the "bodyOnLoad ()" function so that I can
contintue the test?
In addition, if I remove the onload="bodyOnL oad();" block, each page is ok
to run under F5 debug , but each time their construct will be called only
once rather than second time. So I also doubt whether the problem is due to
the "bodyOnLoad ()" function ?
Please check out the above things. If you have any new findings, 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
the onload="Onload. .." has nothing to do with that. That was client side javascript left over from the project that got messed up. According to my discovers as stated before it appears that naming a class _default is causing the constructor to be called twice.
In the attached project or by going
File -> New Web Project ->
Switch to HTML view and copy the HTML code provided in my project - remove the onload so you do not get JS errors.
Switch back to Design view and double click and then copy the code i provided in the Page_Loa
set a breakpoint here or create a constructor and put a breakpoint in there.
Then Project -> Add New Page -> Default.aspx
Repeate the above steps and then set it up as the Start page
On every single new project that I created the minute I did this whenever i ran the project the constructor was called twice.
And as I described before renaming the class to something normal does not rectify the problem. I had to manually close the project and create a new one in order to get it working.
(I can't believe it is not reproduceable as i've been able to do it every single time once i figured it out exactly what was causing the problem) namely having a web form called Default.aspx which would create a class called _Default
Weee. 5th project wasted. 3rd day wasted. I am not sure how this is not coming up as reproduceable as i've laid waste to many hours rebuilding projects only to have it show back up. I think this time it showed up by me just renaming Webform1.aspx to a Default.aspx while leaving the class name the same. Going to spend a few more hours destroying and rebuilding from scratch again
Hi,
I'm viewing the issue and found that this is the same one with another
thread subjected:
BUG: Setting Server Control's InnerHtml forces Constructore to be called.
I've repro your problem and found the root cause of the issue. Also, I've
posted my reply in that one. Please check out it and feel free to post
there if you have any questions on it. Thanks.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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.
|
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>")
|
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...
| |
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();")
|
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...
|
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/
|
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
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |