|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Embedding a web page output into asp.net webform (C#)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 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 -- Show quoteHide quoteMY 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 > > 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 >> >> > > 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 -- Show quoteHide quoteMY 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 > >> > >> > > > > > > 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 >> >> >> >> >> > >> > >> >> > > 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 -- Show quoteHide quoteMY 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 x=getpage("http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mnews: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 > ozilla%3Aen-US%3Aofficial&q=asp.net+&btnG=Search"); Show quoteHide quote > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.asp> > > 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: > > 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 > >> >> > >> >> > >> > > >> > > >> > >> > > > > > > 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 >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> >> > >> > >> >> > >
Other interesting topics
The Demise of the Art of Programming
Handle HttpRequestValidationException gracefully Making objects move along with resizing browser page ? FCKeditor implementation in ASP.NET Nesting Literal Control in anchor tags Combining 2 variables Problem with databinding expression Q: DataGrid during edit IE messing up with font of web pages. Q: check users in Active Directory |
|||||||||||||||||||||||