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

S

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
 
K

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!)
 
S

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
 
K

Karl Seguin

Opps..sorry, should have read your email more closely :)

From the MSDN Process documentation:
http://msdn.microsoft.com/library/d...iagnosticsprocessclassstandardoutputtopic.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!)
 
S

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&...mozilla:en-US:official&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
 
K

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!)
Skeptical said:
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 said:
Opps..sorry, should have read your email more closely :)

From the MSDN Process documentation:
http://msdn.microsoft.com/library/d...iagnosticsprocessclassstandardoutputtopic.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!)
figure
out
 
S

Skeptical

Yay!

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

Karl Seguin said:
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 said:
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 said:
Opps..sorry, should have read your email more closely :)

From the MSDN Process documentation:
http://msdn.microsoft.com/library/d...iagnosticsprocessclassstandardoutputtopic.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!)
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 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!)
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top