Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > How do i use mshtml

Reply
Thread Tools

How do i use mshtml

 
 
Mathew George
Guest
Posts: n/a
 
      07-17-2003
Hello,

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

Mathew


 
Reply With Quote
 
 
 
 
Rob Mayo
Guest
Posts: n/a
 
      07-18-2003
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hello,
>
> How do i use mshtml in asp for parsing an html file.
> Can anyone give the code in vb.....
>
> Mathew
>
>

 
Reply With Quote
 
 
 
 
Mathew George
Guest
Posts: n/a
 
      07-18-2003
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hello,
>
> How do i use mshtml in asp for parsing an html file.
> Can anyone give the code in vb.....
>
> Mathew
>
>


 
Reply With Quote
 
Rob Mayo
Guest
Posts: n/a
 
      07-18-2003
try switching that back to webbrowser. I might have been screwing with something
"Mathew George" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hello,
>
> How do i use mshtml in asp for parsing an html file.
> Can anyone give the code in vb.....
>
> Mathew
>
>

 
Reply With Quote
 
Rob Mayo
Guest
Posts: n/a
 
      07-19-2003
i also remember I had to make a COM interop for them. (probably a given)
"Mathew George" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hello,
>
> How do i use mshtml in asp for parsing an html file.
> Can anyone give the code in vb.....
>
> Mathew
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how can you use mshtml DOM object to grab rendered asp.net page? Randall Arnold ASP .Net 24 01-05-2006 05:00 PM
problem with mshtml.IHTMLInputFileElement Balu ASP .Net 0 07-24-2005 07:56 AM
problem with mshtml.IHTMLInputFileElement Balu ASP .Net 0 07-24-2005 07:45 AM
MSHTML Mathew George ASP .Net 1 07-25-2003 06:25 PM



Advertisments