By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

Cleanly handling load errors when using WinForms controls in IE

P: n/a
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.
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

Jul 21 '05 #2

P: n/a
ti******@online.microsoft.com (Tian Min Huang) wrote in message news:<hh*************@cpmsftngxa07.phx.gbl>...
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.
Jul 21 '05 #3

P: n/a
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.

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.