Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reading html body through ASP.Net

Reply
Thread Tools

Reading html body through ASP.Net

 
 
Luqman
Guest
Posts: n/a
 
      12-06-2004
How can I retrieve text from html file and write to textbox.

Best Regards,

Luqman


 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      12-06-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How can I retrieve text from html file and write to textbox.
>
> Best Regards,
>
> Luqman
>
>



 
Reply With Quote
 
 
 
 
Matt Berther
Guest
Posts: n/a
 
      12-06-2004
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
>



 
Reply With Quote
 
Luqman
Guest
Posts: n/a
 
      12-08-2004
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:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> How can I retrieve text from html file and write to textbox.
>>
>> Best Regards,
>>
>> Luqman
>>
>>

>
>



 
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
To reduce your body weight & slim your body Loss weight MCSA 0 07-23-2007 07:54 PM
To reduce your body weight & slim your body Loss weight MCSA 0 07-21-2007 05:15 AM
all the text (including tags) between <body> .. </body> tarakparekh@yahoo.com Perl Misc 5 09-07-2005 11:40 PM
How to read the BODY of HTML file from another HTML file using javascript? Dhanasankar S via DotNetMonster.com ASP .Net 0 02-26-2005 10:58 AM
Not detecting body.scrollTop and body.scrollLeft in IE6 London Boy Javascript 2 01-12-2004 08:44 AM



Advertisments