Click here to Skip to main content
15,893,381 members
Articles / Programming Languages / C#

WebBrowserControl for the .NET Framework 1.1

Rate me:
Please Sign up or sign in to vote.
3.06/5 (11 votes)
15 Apr 2010CPOL2 min read 98.8K   1.6K   21  
An implementation of a web browser control for the .NET Framework 1.1.
namespace Pajocomo.Windows.Forms
{

    /// <summary>
    /// Represents the method that will handle the <see cref="WebBrowserControl.NavigateError"/> event of the <see cref="WebBrowserControl"/>.
    /// </summary>
    /// <param name="sender">
    /// The source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="NavigateErrorEventArgs"/> that contains the event data. 
    /// </param>
    public delegate void NavigateErrorEventHandler(object sender, NavigateErrorEventArgs e);

    /// <summary>
    /// Provides data for the <see cref="WebBrowserControl.NavigateError"/> event.
    /// </summary>
    public class NavigateErrorEventArgs : System.ComponentModel.CancelEventArgs
    {

        #region Private Instance Fields

        private IWebBrowserObject webBrowser;
        private string url;
        private string targetFrameName;
        private NavigateErrorStatus statusCode;

        #endregion

        #region Private Instance Constructors

        private NavigateErrorEventArgs() {}

        #endregion

        #region Internal Instance Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NavigateErrorEventArgs"/> class with the <see cref="WebBrowser"/>, <see cref="Url"/>, <see cref="TargetFrameName"/> and <see cref="StatusCode"/> properties set to the given values.
        /// </summary>
        /// <param name="webBrowser">
        /// The <see cref="IWebBrowserObject"/> that represents the window or frame in which the navigation error occurred.
        /// </param>
        /// <param name="url">
        /// The URL for which navigation failed.
        /// </param>
        /// <param name="targetFrame">
        /// The name of the frame or window in which the resource is to be displayed, or a null reference (Nothing in Visual Basic) if no named frame or window was targeted for the resource. 
        /// </param>
        /// <param name="statusCode">
        /// A <see cref="NavigateErrorStatus"/> error status code.
        /// </param>
        /// <param name="cancel">
        /// <see langword="true"/> to cancel the event; otherwise, <see langword="false"/>.
        /// </param>
        internal NavigateErrorEventArgs(IWebBrowserObject webBrowser, string url, string targetFrame, NavigateErrorStatus statusCode, bool cancel) : base(cancel)
        {
            this.webBrowser = webBrowser;
            this.url = url;
            this.targetFrameName = targetFrame;
            this.statusCode = statusCode;
        }

        #endregion

        #region Public Instance Properties

        /// <summary>
        /// Gets the <see cref="IWebBrowserObject"/> that represents the window or frame in which the navigation error occurred.
        /// </summary>
        /// <value>
        /// The <see cref="IWebBrowserObject"/> that represents the window or frame in which the navigation error occurred.
        /// </value>
        public IWebBrowserObject WebBrowser
        {
            get
            {
                return this.webBrowser;
            }
        }

        /// <summary>
        /// Gets the URL for which navigation failed.
        /// </summary>
        /// <value>
        /// The URL for which navigation failed.
        /// </value>
        public string Url
        {
            get
            {
                return this.url;
            }
        }

        /// <summary>
        /// Gets the name of the frame or window in which the resource is to be displayed, or a null reference (Nothing in Visual Basic) if no named frame or window was targeted for the resource. 
        /// </summary>
        /// <value>
        /// The name of the frame in which or window the resource is to be displayed, or a null reference (Nothing in Visual Basic) if no named frame or window was targeted for the resource. 
        /// </value>
        public string TargetFrameName
        {
            get
            {
                return this.targetFrameName;
            }
        }

        /// <summary>
        /// Gets a <see cref="NavigateErrorStatus"/> error status code.
        /// </summary>
        /// <value>
        /// A <see cref="NavigateErrorStatus"/> error status code.
        /// </value>
        public NavigateErrorStatus StatusCode
        {
            get
            {
                return this.statusCode;
            }
        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Paulo Morgado
Portugal Portugal

Comments and Discussions