How do i use mshtml

Discussion in 'ASP .Net Building Controls' started by Mathew George, Jul 17, 2003.

  1. Hello,

    How do i use mshtml in asp for parsing an html file.
    Can anyone give the code in vb.....

    Mathew
    Mathew George, Jul 17, 2003
    #1
    1. Advertising

  2. Mathew George

    Rob Mayo Guest

    Back when I was fooling around with this for the first time, I made a web app that had a textbox. Users would enter HTML in the box and submit the form to the page. I would then parse the images out of that page and save them. Here is a sample. You can start from there.



    Imports MSHTML
    Imports SHDocVw
    Public Class TestHTMLDOM
    Inherits System.Web.UI.Page
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim htmlDOM As IHTMLDocument2
    Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()

    brwTest.Navigate("about:blank")
    htmlDOM = brwTest.Document
    htmlDOM.body.innerHTML = Request.Form("HTMLSource")

    Dim objI As IHTMLElement
    For Each objI In htmlDOM.images
    objI.src = "/KnowledgeBase/Support/4/test.gif"
    Next

    Me.TextBox1.Text = htmlDOM.body.innerHTML

    htmlDOM = Nothing
    brwTest.Dispose()

    End Sub
    End Class






    "Mathew George" <> wrote in message news:...
    > Hello,
    >
    > How do i use mshtml in asp for parsing an html file.
    > Can anyone give the code in vb.....
    >
    > Mathew
    >
    >
    Rob Mayo, Jul 18, 2003
    #2
    1. Advertising

  3. I tried to ececute the same code given by rob, i got an error message.

    error message are as
    -----------------------------------------

    Server Error in '/NFTE' Application.
    --------------------------------------------------------------------------------

    Access is denied.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.UnauthorizedAccessException: Access is denied.

    The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

    Source Error:


    Line 28: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Line 29: Dim htmlDOM As IHTMLDocument2
    Line 30: Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()



    -----------------------------------------------------

    I have given rights access to "{machinename}\ASPNET then also it gave me the same error.............
    Help please.

    Mathew

    "Rob Mayo" <> wrote in message news:#...
    Back when I was fooling around with this for the first time, I made a web app that had a textbox. Users would enter HTML in the box and submit the form to the page. I would then parse the images out of that page and save them. Here is a sample. You can start from there.



    Imports MSHTML
    Imports SHDocVw
    Public Class TestHTMLDOM
    Inherits System.Web.UI.Page
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim htmlDOM As IHTMLDocument2
    Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()

    brwTest.Navigate("about:blank")
    htmlDOM = brwTest.Document
    htmlDOM.body.innerHTML = Request.Form("HTMLSource")

    Dim objI As IHTMLElement
    For Each objI In htmlDOM.images
    objI.src = "/KnowledgeBase/Support/4/test.gif"
    Next

    Me.TextBox1.Text = htmlDOM.body.innerHTML

    htmlDOM = Nothing
    brwTest.Dispose()

    End Sub
    End Class






    "Mathew George" <> wrote in message news:...
    > Hello,
    >
    > How do i use mshtml in asp for parsing an html file.
    > Can anyone give the code in vb.....
    >
    > Mathew
    >
    >
    Mathew George, Jul 18, 2003
    #3
  4. Mathew George

    Rob Mayo Guest

    try switching that back to webbrowser. I might have been screwing with something
    "Mathew George" <> wrote in message news:#...
    I tried to ececute the same code given by rob, i got an error message.

    error message are as
    -----------------------------------------

    Server Error in '/NFTE' Application.
    ------------------------------------------------------------------------------

    Access is denied.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.UnauthorizedAccessException: Access is denied.

    The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

    Source Error:


    Line 28: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Line 29: Dim htmlDOM As IHTMLDocument2
    Line 30: Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()


    -----------------------------------------------------

    I have given rights access to "{machinename}\ASPNET then also it gave me the same error.............
    Help please.

    Mathew

    "Rob Mayo" <> wrote in message news:#...
    Back when I was fooling around with this for the first time, I made a web app that had a textbox. Users would enter HTML in the box and submit the form to the page. I would then parse the images out of that page and save them. Here is a sample. You can start from there.



    Imports MSHTML
    Imports SHDocVw
    Public Class TestHTMLDOM
    Inherits System.Web.UI.Page
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim htmlDOM As IHTMLDocument2
    Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()

    brwTest.Navigate("about:blank")
    htmlDOM = brwTest.Document
    htmlDOM.body.innerHTML = Request.Form("HTMLSource")

    Dim objI As IHTMLElement
    For Each objI In htmlDOM.images
    objI.src = "/KnowledgeBase/Support/4/test.gif"
    Next

    Me.TextBox1.Text = htmlDOM.body.innerHTML

    htmlDOM = Nothing
    brwTest.Dispose()

    End Sub
    End Class






    "Mathew George" <> wrote in message news:...
    > Hello,
    >
    > How do i use mshtml in asp for parsing an html file.
    > Can anyone give the code in vb.....
    >
    > Mathew
    >
    >
    Rob Mayo, Jul 18, 2003
    #4
  5. Mathew George

    Rob Mayo Guest

    i also remember I had to make a COM interop for them. (probably a given)
    "Mathew George" <> wrote in message news:#...
    I tried to ececute the same code given by rob, i got an error message.

    error message are as
    -----------------------------------------

    Server Error in '/NFTE' Application.
    ------------------------------------------------------------------------------

    Access is denied.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.UnauthorizedAccessException: Access is denied.

    The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

    Source Error:


    Line 28: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Line 29: Dim htmlDOM As IHTMLDocument2
    Line 30: Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()


    -----------------------------------------------------

    I have given rights access to "{machinename}\ASPNET then also it gave me the same error.............
    Help please.

    Mathew

    "Rob Mayo" <> wrote in message news:#...
    Back when I was fooling around with this for the first time, I made a web app that had a textbox. Users would enter HTML in the box and submit the form to the page. I would then parse the images out of that page and save them. Here is a sample. You can start from there.



    Imports MSHTML
    Imports SHDocVw
    Public Class TestHTMLDOM
    Inherits System.Web.UI.Page
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim htmlDOM As IHTMLDocument2
    Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()

    brwTest.Navigate("about:blank")
    htmlDOM = brwTest.Document
    htmlDOM.body.innerHTML = Request.Form("HTMLSource")

    Dim objI As IHTMLElement
    For Each objI In htmlDOM.images
    objI.src = "/KnowledgeBase/Support/4/test.gif"
    Next

    Me.TextBox1.Text = htmlDOM.body.innerHTML

    htmlDOM = Nothing
    brwTest.Dispose()

    End Sub
    End Class






    "Mathew George" <> wrote in message news:...
    > Hello,
    >
    > How do i use mshtml in asp for parsing an html file.
    > Can anyone give the code in vb.....
    >
    > Mathew
    >
    >
    Rob Mayo, Jul 19, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mathew George

    MSHTML

    Mathew George, Jul 17, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,176
    Scott M.
    Jul 25, 2003
  2. Balu
    Replies:
    0
    Views:
    859
  3. Balu
    Replies:
    0
    Views:
    532
  4. DotNetShadow

    MSHTML asp.net web application SLOW

    DotNetShadow, Nov 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,760
    DotNetShadow
    Nov 19, 2003
  5. Randall Arnold
    Replies:
    24
    Views:
    5,001
    Randall Arnold
    Jan 5, 2006
Loading...

Share This Page