PC Review


Reply
Thread Tools Rate Thread

Cleanly handling load errors when using WinForms controls in IE

 
 
Dan Foody
Guest
Posts: n/a
 
      11th Dec 2003
I've embedded a .NET 1.1 control in a web page for use in IE (using
the "object" tag). There are two challenges I'm facing: if the
machine does not have the 1.1 framework installed or if the .NET
security does not allow the control to initialize the user is faced
with a big blank area and won't know what to do about it.

How would I go about redirecting the user to a help page only if the
control can't initialize? Or are there alternate approaches someone
can recommend?

Thanks.
 
Reply With Quote
 
 
 
 
Tian Min Huang
Guest
Posts: n/a
 
      12th Dec 2003
Hi,

Thanks for your post.

>> How would I go about redirecting the user to a help page only if the

control can't initialize?
I believe that it's a good idea. If it fails to create the control, you can
call the following code to redirect the web page:

window.navigate("error.htm");

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
Dan Foody
Guest
Posts: n/a
 
      12th Dec 2003
(E-Mail Removed) (Tian Min Huang) wrote in message news:<(E-Mail Removed)>...
> Hi,
>
> Thanks for your post.
>
> >> How would I go about redirecting the user to a help page only if the

> control can't initialize?
> I believe that it's a good idea. If it fails to create the control, you can
> call the following code to redirect the web page:
>
> window.navigate("error.htm");


The challenge I was facing was not how to redirect, but how to trap
the fact that the WinForms control is not properly initialized.

The pure HTML approach (which will fall back to nested HTML or a
nested object tag if the outer object can't be initialized) doesn't
work. Trying to use JavaScript with the object element's "onerror"
callback doesn't work.

In the interim I discovered the answer: Trigger some JavaScript to
fire "onload" of the page. In that JavaScript code, check whether a
property of the control has a value you expect it to have. If not,
the control has not initialized properly.
 
Reply With Quote
 
Tian Min Huang
Guest
Posts: n/a
 
      15th Dec 2003
Hello,

Sorry for the misunderstanding. I suggest you to add window.onerror handler
for all script errors that occur anywhere on a Web page. It looks like this:

...
<SCRIPT language=JavaScript>

function errorHandler(message, url, line)
{
// message == text-based error description
// url == url which exhibited the script error
// line == the line number being executed when the error occurred

// handle the error here

// stop the event from bubbling up to the default window.onerror handler
// (see the "For More Info" section for an article on event bubbling)
return true;
}

// install the global error-handler
window.onerror = errorHandler;
</SCRIPT>

Please refer to the following MSDN article for detailed information:

Handling and Avoiding Web Page Errors Part 2: Run-Time Errors
http://msdn.microsoft.com/library/de...us/dnscrpt/htm
l/WebErrors2.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
creation of controls dynamically and handling the controls Murthy Microsoft VB .NET 1 18th Mar 2005 08:26 AM
Handling Exceptions in WinForms Jack Wright Microsoft Dot NET Framework Forms 5 2nd Jun 2004 10:43 AM
winforms: handling enter key for single line edit? PEACEMAKER Microsoft C# .NET 2 3rd May 2004 06:31 AM
winforms controls take a long time to load in IE =?Utf-8?B?Sm9obiBBbGVzc2U=?= Microsoft ASP .NET 2 3rd Feb 2004 02:49 AM
Exception Handling + Winforms Ori Microsoft C# .NET 7 21st Jan 2004 08:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 PM.