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

Reading html body through ASP.Net

P: n/a
How can I retrieve text from html file and write to textbox.

Best Regards,

Luqman
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello Luqman,

using (StreamReader rdr = new StreamReader("c:\path\to\my\file.html"))
{
string text = rdr.ReadToEnd();

// at this point, you have the text of the HTML file in a variable.
// do with it what you need to...
}

--
Matt Berther
http://www.mattberther.com
How can I retrieve text from html file and write to textbox.

Best Regards,

Luqman

Nov 19 '05 #2

P: n/a
From another site? Or from the local file system? Here's a method for
reading from another site:

<form id="form1" runat="server">
<asp:TextBox id="txtURI" runat="server" Width="552px"></asp:TextBox>
<asp:Button id="cmdSubmit" runat="server" Text="Button"></asp:Button><br>
<asp:TextBox id="txtHTML" runat="server" TextMode="MultiLine" Width="616px"
Height="552px"></asp:TextBox></P>
</form>

Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click
Dim oRequest As System.Net.WebRequest
Dim oResponse As System.Net.WebResponse
Dim oReader As System.IO.StreamReader
Dim sResponse As String
Try
oRequest = System.Net.WebRequest.Create(txtURI.Text)
oResponse = oRequest.GetResponse
oReader = New System.IO.StreamReader(oResponse.GetResponseStream )
sResponse = oReader.ReadToEnd
Catch : sResponse = "Could not load page"
End Try
txtHTML.Text = sResponse
End Sub

Ray at work

"Luqman" <pe*******@cyber.net.pk> wrote in message
news:eR**************@TK2MSFTNGP12.phx.gbl...
How can I retrieve text from html file and write to textbox.

Best Regards,

Luqman

Nov 19 '05 #3

P: n/a
Hi Ray,

Your code is returning Html source, but I need html Output in textbox or
rich text box. Whatever you see in the browser when you click on html file,
I want to display same in rich text box, so that formatted text
(bold/underline) could be displayed, html file could be on local computer or
could be anywhere in web site.

I want to use the html formatted text in my mailmerge application.

The user create a message in any software like outlook express, microsoft
outlook or frontpage and save it in html format. Then using my application,
he can send mailmerge messages using message body from html file.

I hope you understand what I mean.

Best Regards,

Luqman

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
From another site? Or from the local file system? Here's a method for
reading from another site:

<form id="form1" runat="server">
<asp:TextBox id="txtURI" runat="server" Width="552px"></asp:TextBox>
<asp:Button id="cmdSubmit" runat="server" Text="Button"></asp:Button><br>
<asp:TextBox id="txtHTML" runat="server" TextMode="MultiLine"
Width="616px"
Height="552px"></asp:TextBox></P>
</form>

Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click
Dim oRequest As System.Net.WebRequest
Dim oResponse As System.Net.WebResponse
Dim oReader As System.IO.StreamReader
Dim sResponse As String
Try
oRequest = System.Net.WebRequest.Create(txtURI.Text)
oResponse = oRequest.GetResponse
oReader = New System.IO.StreamReader(oResponse.GetResponseStream )
sResponse = oReader.ReadToEnd
Catch : sResponse = "Could not load page"
End Try
txtHTML.Text = sResponse
End Sub

Ray at work

"Luqman" <pe*******@cyber.net.pk> wrote in message
news:eR**************@TK2MSFTNGP12.phx.gbl...
How can I retrieve text from html file and write to textbox.

Best Regards,

Luqman


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.