473,395 Members | 1,527 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,395 software developers and data experts.

Stop further execution in Page_Load

Folks,

My ASPX page uses a custom user control. What happens here is that
when a runtime error occurs in the ASPX page, the error is caught in
the error handler and then strangely, the execution continues to the
custom user control code and it blows there because of the error
occured initially in the ASPX page. When it blows it displays as
unhandled error even though I have try catch in my ASPX page and in
the custom user control.

Is there a way to stop execution if an error occurs in the Page_Load
method and return the contents gathered so far back to the client
(along with the error)?

I tried Response.End and it returns an emppty screen to the client. I
wanted to display whatever has been processed until the point where
the error occured. Pls note this works fine for normal ASPX page but
when I use a custom user control in my ASPX page then the execution
continues to the custom user control code even after an error occured
and caught in my ASPX page's try catch block.

Any thoughts pls?
Nov 18 '05 #1
2 8545
"Gopal Krish" <ge*****@yahoo.com> wrote in message news:8b**************************@posting.google.c om...
Is there a way to stop execution if an error occurs in the Page_Load
method and return the contents gathered so far back to the client
(along with the error)?

I tried Response.End and it returns an emppty screen to the client. I
wanted to display whatever has been processed until the point where
the error occured.


I would answer Response.End as well. The reason you're seeing an empty
screen is because during Page_Load -- that is all the content you have. No
HTML is produced until Render (remember the page lifecycle: Init, Load,
PreRender, Render, and Unload).

If you want your catch statement to remove the offending WebControl(s)
from the Page, so other controls can go on to render, that's one approach
you could use (but you'll also require a way to dynamically put it back in
Page_Init when the situation is repaired, if that's what you're going for).

My suspicion is that you're not catching the exception from the user control,
probably because you have try..catch in the Load events, but not during the
processing wherein ASP.NET calls Render( ) on the Page and your User-
Control. If your Page_Load begins with try and ends with catch, you're
still missing out on the majority of the processing.
Derek Harmon
Nov 18 '05 #2
Thanks Derek. Now I understand the process fully. I think I should be
able to handle it now.

Thanks
"Derek Harmon" <lo*******@msn.com> wrote in message news:<OM**************@TK2MSFTNGP12.phx.gbl>...
"Gopal Krish" <ge*****@yahoo.com> wrote in message news:8b**************************@posting.google.c om...
Is there a way to stop execution if an error occurs in the Page_Load
method and return the contents gathered so far back to the client
(along with the error)?

I tried Response.End and it returns an emppty screen to the client. I
wanted to display whatever has been processed until the point where
the error occured.


I would answer Response.End as well. The reason you're seeing an empty
screen is because during Page_Load -- that is all the content you have. No
HTML is produced until Render (remember the page lifecycle: Init, Load,
PreRender, Render, and Unload).

If you want your catch statement to remove the offending WebControl(s)
from the Page, so other controls can go on to render, that's one approach
you could use (but you'll also require a way to dynamically put it back in
Page_Init when the situation is repaired, if that's what you're going for).

My suspicion is that you're not catching the exception from the user control,
probably because you have try..catch in the Load events, but not during the
processing wherein ASP.NET calls Render( ) on the Page and your User-
Control. If your Page_Load begins with try and ends with catch, you're
still missing out on the majority of the processing.
Derek Harmon

Nov 18 '05 #3

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

Similar topics

0
by: Matt | last post by:
I'm attempting to load a form, query a database, and update a progress bar on the same form. I want the form to load and activate/enable the form's cancel button while the code continues to...
9
by: Rea | last post by:
Hi eb I set some 'Stop' statements and also visual breakpoints in asp code (vbscript). I am doing that in Microsoft Script debugger. Than I refresh the original page and expect execution to halt...
2
by: howa | last post by:
Are there any method to stop the current JS execution on a page safely, something like PHP's die() functuin ?
4
by: Ralphz | last post by:
Hi How do I stop JavaScript execution when I encounter an error? Is there something similar to PHP's exit or die function? Thanks Ralph
3
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post by:
Hi All, I have a ASP/C# application that connect to Oracle database . After issuing my SQL query if I close the browser or move into another page ( ie whle executing in the databse serevr) will...
2
by: Bruno Rafael Moreira de Barros | last post by:
index.php --- inlcude 'application.php'; functions.php --- function test1() { trigger_error('My error'); return FALSE;
7
by: blublu123 | last post by:
Hi all, I have a number of fields on various forms that need data validation. If fields are empty (null), the form should not save and close, and the cursor should go to the appropriate field. I...
4
by: sphinney | last post by:
Hi everyone. I'm creating an application inside Access 2007. The application will retrieve data from various locations on my company's network servers. Depending on the time of day, alignment of...
3
by: GiJeet | last post by:
I put the the button property in the watch window but it doesn't stop when the property changes value. For example I put this.myButton.Visible in the watch window with an initial value of false...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
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...
0
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...

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.