Cleanly handling load errors when using WinForms controls in IE

  • Thread starter Thread starter Dan Foody
  • Start date Start date
D

Dan Foody

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.
 
Hi,

Thanks for your post.
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.
 
Hi,

Thanks for your post.

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.
 
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/default.asp?url=/library/en-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.
 
Back
Top