Home All Groups Group Topic Archive Search About

Embedding a web page output into asp.net webform (C#)

Author
21 Mar 2005 4:54 PM
Skeptical
Hello,

I am trying to embed html output into my webform but could not figure out
how to so far.

The form will execute a Perl script with some parameters, and script will
output some html code. I need to capture and render this html into my
webform.

Any ideas?

Thanks

Author
21 Mar 2005 5:00 PM
Karl Seguin
Read the file into a string and set the Text property of a literal to the
value:

StreamReader sr = null;
string content = "";
try
{
  sr = new StreamReader("c:\\someFile.html");
  content = sr.ReadToEnd();
}finally
{
  if (sr != null)
  {
    sr.Close();
  }
}
SomeLiteral.Text = content;

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Show quoteHide quote
"Skeptical" <s***@yahoo.com> wrote in message
news:O$1AxajLFHA.2824@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am trying to embed html output into my webform but could not figure out
> how to so far.
>
> The form will execute a Perl script with some parameters, and script will
> output some html code. I need to capture and render this html into my
> webform.
>
> Any ideas?
>
> Thanks
>
>
Are all your drivers up to date? click for free checkup

Author
21 Mar 2005 6:07 PM
Skeptical
Thanks, but there is no file to read from. The Perl script should be
executed, and then the outputting html should be rendered into the asp.net
webform.

I am basically looking for something like lwp in Perl
http://lwp.linpro.no/lwp/

to get the html and then some method to dynamically render it

Thanks

Show quoteHide quote
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uKgU$djLFHA.3016@TK2MSFTNGP15.phx.gbl...
> Read the file into a string and set the Text property of a literal to the
> value:
>
> StreamReader sr = null;
> string content = "";
> try
> {
>  sr = new StreamReader("c:\\someFile.html");
>  content = sr.ReadToEnd();
> }finally
> {
>  if (sr != null)
>  {
>    sr.Close();
>  }
> }
> SomeLiteral.Text = content;
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "Skeptical" <s***@yahoo.com> wrote in message
> news:O$1AxajLFHA.2824@TK2MSFTNGP10.phx.gbl...
>> Hello,
>>
>> I am trying to embed html output into my webform but could not figure out
>> how to so far.
>>
>> The form will execute a Perl script with some parameters, and script will
>> output some html code. I need to capture and render this html into my
>> webform.
>>
>> Any ideas?
>>
>> Thanks
>>
>>
>
>
Author
21 Mar 2005 6:17 PM
Karl Seguin
Opps..sorry, should have read your email more closely :)

From the MSDN Process documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.asp

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "test.exe";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();

Is that more what you are looking for?

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Show quoteHide quote
"Skeptical" <s***@yahoo.com> wrote in message
news:uaS8pDkLFHA.3424@TK2MSFTNGP12.phx.gbl...
> Thanks, but there is no file to read from. The Perl script should be
> executed, and then the outputting html should be rendered into the asp.net
> webform.
>
> I am basically looking for something like lwp in Perl
> http://lwp.linpro.no/lwp/
>
> to get the html and then some method to dynamically render it
>
> Thanks
>
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:uKgU$djLFHA.3016@TK2MSFTNGP15.phx.gbl...
> > Read the file into a string and set the Text property of a literal to
the
> > value:
> >
> > StreamReader sr = null;
> > string content = "";
> > try
> > {
> >  sr = new StreamReader("c:\\someFile.html");
> >  content = sr.ReadToEnd();
> > }finally
> > {
> >  if (sr != null)
> >  {
> >    sr.Close();
> >  }
> > }
> > SomeLiteral.Text = content;
> >
> > Karl
> >
> > --
> > MY ASP.Net tutorials
> > http://www.openmymind.net/ - New and Improved (yes, the popup is
> > annoying)
> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> > come!)
> > "Skeptical" <s***@yahoo.com> wrote in message
> > news:O$1AxajLFHA.2824@TK2MSFTNGP10.phx.gbl...
> >> Hello,
> >>
> >> I am trying to embed html output into my webform but could not figure
out
> >> how to so far.
> >>
> >> The form will execute a Perl script with some parameters, and script
will
> >> output some html code. I need to capture and render this html into my
> >> webform.
> >>
> >> Any ideas?
> >>
> >> Thanks
> >>
> >>
> >
> >
>
>
Author
21 Mar 2005 6:55 PM
Skeptical
Nope. I am not trying to run an executable, I am trying to retrieve a web
page into my asp.net webform. Here is an example,

for example let's say we have a webform called test.aspx

when we run test.aspx

we should have something like

private void Page_Load(object sender, System.EventArgs e)

{

Label1.Text="Hello World";

string
x=getpage("http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=asp.net+&btnG=Search");



render(string);

Label2.Text"Bye Bye";

}

getpage() should be able to retrieve all html from the given url, now the
second challenge is to actually render this into the test.aspx so I might
have something like:

Hello World
[
Google Page
]
Bye Bye

I thought Microsoft had already done something similar but I could not find
anything.

Thanks

Show quoteHide quote
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u8xkBJkLFHA.568@TK2MSFTNGP09.phx.gbl...
> Opps..sorry, should have read your email more closely :)
>
> From the MSDN Process documentation:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.asp
>
> Process p = new Process();
> p.StartInfo.UseShellExecute = false;
> p.StartInfo.RedirectStandardOutput = true;
> p.StartInfo.FileName = "test.exe";
> p.Start();
> p.WaitForExit();
> string output = p.StandardOutput.ReadToEnd();
>
> Is that more what you are looking for?
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "Skeptical" <s***@yahoo.com> wrote in message
> news:uaS8pDkLFHA.3424@TK2MSFTNGP12.phx.gbl...
>> Thanks, but there is no file to read from. The Perl script should be
>> executed, and then the outputting html should be rendered into the
>> asp.net
>> webform.
>>
>> I am basically looking for something like lwp in Perl
>> http://lwp.linpro.no/lwp/
>>
>> to get the html and then some method to dynamically render it
>>
>> Thanks
>>
>> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
>> wrote in message news:uKgU$djLFHA.3016@TK2MSFTNGP15.phx.gbl...
>> > Read the file into a string and set the Text property of a literal to
> the
>> > value:
>> >
>> > StreamReader sr = null;
>> > string content = "";
>> > try
>> > {
>> >  sr = new StreamReader("c:\\someFile.html");
>> >  content = sr.ReadToEnd();
>> > }finally
>> > {
>> >  if (sr != null)
>> >  {
>> >    sr.Close();
>> >  }
>> > }
>> > SomeLiteral.Text = content;
>> >
>> > Karl
>> >
>> > --
>> > MY ASP.Net tutorials
>> > http://www.openmymind.net/ - New and Improved (yes, the popup is
>> > annoying)
>> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
>> > come!)
>> > "Skeptical" <s***@yahoo.com> wrote in message
>> > news:O$1AxajLFHA.2824@TK2MSFTNGP10.phx.gbl...
>> >> Hello,
>> >>
>> >> I am trying to embed html output into my webform but could not figure
> out
>> >> how to so far.
>> >>
>> >> The form will execute a Perl script with some parameters, and script
> will
>> >> output some html code. I need to capture and render this html into my
>> >> webform.
>> >>
>> >> Any ideas?
>> >>
>> >> Thanks
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Author
21 Mar 2005 8:12 PM
Karl Seguin
heh...well, we are getting closer :)  seems like you want some screen
scraping..  a google search for C# screen scraping should get you somewhere.
You can do it with the HttpWebRequest class, or with a web service.

http://www.csharpfriends.com/Articles/getTip.aspx?articleID=210

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Show quoteHide quote
"Skeptical" <s***@yahoo.com> wrote in message
news:OiNKNekLFHA.3616@TK2MSFTNGP09.phx.gbl...
> Nope. I am not trying to run an executable, I am trying to retrieve a web
> page into my asp.net webform. Here is an example,
>
> for example let's say we have a webform called test.aspx
>
> when we run test.aspx
>
> we should have something like
>
> private void Page_Load(object sender, System.EventArgs e)
>
> {
>
> Label1.Text="Hello World";
>
> string
>
x=getpage("http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.m
ozilla%3Aen-US%3Aofficial&q=asp.net+&btnG=Search");
Show quoteHide quote
>
>
>
> render(string);
>
> Label2.Text"Bye Bye";
>
> }
>
> getpage() should be able to retrieve all html from the given url, now the
> second challenge is to actually render this into the test.aspx so I might
> have something like:
>
> Hello World
> [
> Google Page
> ]
> Bye Bye
>
> I thought Microsoft had already done something similar but I could not
find
> anything.
>
> Thanks
>
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:u8xkBJkLFHA.568@TK2MSFTNGP09.phx.gbl...
> > Opps..sorry, should have read your email more closely :)
> >
> > From the MSDN Process documentation:
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.asp
Show quoteHide quote
> >
> > Process p = new Process();
> > p.StartInfo.UseShellExecute = false;
> > p.StartInfo.RedirectStandardOutput = true;
> > p.StartInfo.FileName = "test.exe";
> > p.Start();
> > p.WaitForExit();
> > string output = p.StandardOutput.ReadToEnd();
> >
> > Is that more what you are looking for?
> >
> > Karl
> > --
> > MY ASP.Net tutorials
> > http://www.openmymind.net/ - New and Improved (yes, the popup is
> > annoying)
> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> > come!)
> > "Skeptical" <s***@yahoo.com> wrote in message
> > news:uaS8pDkLFHA.3424@TK2MSFTNGP12.phx.gbl...
> >> Thanks, but there is no file to read from. The Perl script should be
> >> executed, and then the outputting html should be rendered into the
> >> asp.net
> >> webform.
> >>
> >> I am basically looking for something like lwp in Perl
> >> http://lwp.linpro.no/lwp/
> >>
> >> to get the html and then some method to dynamically render it
> >>
> >> Thanks
> >>
> >> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
> >> wrote in message news:uKgU$djLFHA.3016@TK2MSFTNGP15.phx.gbl...
> >> > Read the file into a string and set the Text property of a literal to
> > the
> >> > value:
> >> >
> >> > StreamReader sr = null;
> >> > string content = "";
> >> > try
> >> > {
> >> >  sr = new StreamReader("c:\\someFile.html");
> >> >  content = sr.ReadToEnd();
> >> > }finally
> >> > {
> >> >  if (sr != null)
> >> >  {
> >> >    sr.Close();
> >> >  }
> >> > }
> >> > SomeLiteral.Text = content;
> >> >
> >> > Karl
> >> >
> >> > --
> >> > MY ASP.Net tutorials
> >> > http://www.openmymind.net/ - New and Improved (yes, the popup is
> >> > annoying)
> >> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more
to
> >> > come!)
> >> > "Skeptical" <s***@yahoo.com> wrote in message
> >> > news:O$1AxajLFHA.2824@TK2MSFTNGP10.phx.gbl...
> >> >> Hello,
> >> >>
> >> >> I am trying to embed html output into my webform but could not
figure
> > out
> >> >> how to so far.
> >> >>
> >> >> The form will execute a Perl script with some parameters, and script
> > will
> >> >> output some html code. I need to capture and render this html into
my
> >> >> webform.
> >> >>
> >> >> Any ideas?
> >> >>
> >> >> Thanks
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>
Author
21 Mar 2005 8:24 PM
Skeptical
Yay!

That's exactly what I have been talking about! Thanks a bunch...

Show quoteHide quote
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OkNFXJlLFHA.1176@TK2MSFTNGP12.phx.gbl...
> heh...well, we are getting closer :)  seems like you want some screen
> scraping..  a google search for C# screen scraping should get you
> somewhere.
> You can do it with the HttpWebRequest class, or with a web service.
>
> http://www.csharpfriends.com/Articles/getTip.aspx?articleID=210
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "Skeptical" <s***@yahoo.com> wrote in message
> news:OiNKNekLFHA.3616@TK2MSFTNGP09.phx.gbl...
>> Nope. I am not trying to run an executable, I am trying to retrieve a web
>> page into my asp.net webform. Here is an example,
>>
>> for example let's say we have a webform called test.aspx
>>
>> when we run test.aspx
>>
>> we should have something like
>>
>> private void Page_Load(object sender, System.EventArgs e)
>>
>> {
>>
>> Label1.Text="Hello World";
>>
>> string
>>
> x=getpage("http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.m
> ozilla%3Aen-US%3Aofficial&q=asp.net+&btnG=Search");
>>
>>
>>
>> render(string);
>>
>> Label2.Text"Bye Bye";
>>
>> }
>>
>> getpage() should be able to retrieve all html from the given url, now the
>> second challenge is to actually render this into the test.aspx so I might
>> have something like:
>>
>> Hello World
>> [
>> Google Page
>> ]
>> Bye Bye
>>
>> I thought Microsoft had already done something similar but I could not
> find
>> anything.
>>
>> Thanks
>>
>> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
>> wrote in message news:u8xkBJkLFHA.568@TK2MSFTNGP09.phx.gbl...
>> > Opps..sorry, should have read your email more closely :)
>> >
>> > From the MSDN Process documentation:
>> >
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.asp
>> >
>> > Process p = new Process();
>> > p.StartInfo.UseShellExecute = false;
>> > p.StartInfo.RedirectStandardOutput = true;
>> > p.StartInfo.FileName = "test.exe";
>> > p.Start();
>> > p.WaitForExit();
>> > string output = p.StandardOutput.ReadToEnd();
>> >
>> > Is that more what you are looking for?
>> >
>> > Karl
>> > --
>> > MY ASP.Net tutorials
>> > http://www.openmymind.net/ - New and Improved (yes, the popup is
>> > annoying)
>> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
>> > come!)
>> > "Skeptical" <s***@yahoo.com> wrote in message
>> > news:uaS8pDkLFHA.3424@TK2MSFTNGP12.phx.gbl...
>> >> Thanks, but there is no file to read from. The Perl script should be
>> >> executed, and then the outputting html should be rendered into the
>> >> asp.net
>> >> webform.
>> >>
>> >> I am basically looking for something like lwp in Perl
>> >> http://lwp.linpro.no/lwp/
>> >>
>> >> to get the html and then some method to dynamically render it
>> >>
>> >> Thanks
>> >>
>> >> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
>> >> net>
>> >> wrote in message news:uKgU$djLFHA.3016@TK2MSFTNGP15.phx.gbl...
>> >> > Read the file into a string and set the Text property of a literal
>> >> > to
>> > the
>> >> > value:
>> >> >
>> >> > StreamReader sr = null;
>> >> > string content = "";
>> >> > try
>> >> > {
>> >> >  sr = new StreamReader("c:\\someFile.html");
>> >> >  content = sr.ReadToEnd();
>> >> > }finally
>> >> > {
>> >> >  if (sr != null)
>> >> >  {
>> >> >    sr.Close();
>> >> >  }
>> >> > }
>> >> > SomeLiteral.Text = content;
>> >> >
>> >> > Karl
>> >> >
>> >> > --
>> >> > MY ASP.Net tutorials
>> >> > http://www.openmymind.net/ - New and Improved (yes, the popup is
>> >> > annoying)
>> >> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more
> to
>> >> > come!)
>> >> > "Skeptical" <s***@yahoo.com> wrote in message
>> >> > news:O$1AxajLFHA.2824@TK2MSFTNGP10.phx.gbl...
>> >> >> Hello,
>> >> >>
>> >> >> I am trying to embed html output into my webform but could not
> figure
>> > out
>> >> >> how to so far.
>> >> >>
>> >> >> The form will execute a Perl script with some parameters, and
>> >> >> script
>> > will
>> >> >> output some html code. I need to capture and render this html into
> my
>> >> >> webform.
>> >> >>
>> >> >> Any ideas?
>> >> >>
>> >> >> Thanks
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>

Bookmark and Share