Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Interact with forms programmatically

Reply
Thread Tools

Interact with forms programmatically

 
 
Ray Booysen
Guest
Posts: n/a
 
      06-27-2006
Hi all

I have a webform with some functionality I need to use. But I need the
page to render first. Is there any way to do this?

I essentially need to instanciate an instance of the page get it to
render without it showing on the screen and then call a method that is
available.

Can this be done?

Regards
Ray
 
Reply With Quote
 
 
 
 
Ray Booysen
Guest
Posts: n/a
 
      06-27-2006
woops, forgot to mention. This is with ASP.net 1.1

Ray Booysen wrote:
> Hi all
>
> I have a webform with some functionality I need to use. But I need the
> page to render first. Is there any way to do this?
>
> I essentially need to instanciate an instance of the page get it to
> render without it showing on the screen and then call a method that is
> available.
>
> Can this be done?
>
> Regards
> Ray

 
Reply With Quote
 
 
 
 
Vadivel Kumar
Guest
Posts: n/a
 
      06-27-2006
Ray Booysen wrote:
> woops, forgot to mention. This is with ASP.net 1.1
>
> Ray Booysen wrote:
>> Hi all
>>
>> I have a webform with some functionality I need to use. But I need
>> the page to render first. Is there any way to do this?
>>
>> I essentially need to instanciate an instance of the page get it to
>> render without it showing on the screen and then call a method that is
>> available.
>>
>> Can this be done?
>>
>> Regards
>> Ray


Hi,

If i assume that you need to execute that page internally and get the ht
ml content, then it is very much possible. In the bottom of this reply
you can find and excerpt that calls the .aspx page using WebRequest
object and populates the html content into Div element.

In other way, if i assume that you want to execute the page just for the
sake of doing some process and with you need to pass some parameters
(means, you have to input some values) for the methods. Then, the only
way is to encapsulate the class that is inherited by the page from
another class and calling its methods to do so.

But, I suggest you should keep the code that needed to be "re-used" for
multi-purpose should be kept in different class and should be called in
appropriate places whenever needed.

Anyways, Let me know if this helps you or I am wrong in any case. And,
check the below code excerpt as well.

-
Vadive

-------
1. Create an ASPX page called "another_domain_info.aspx"
2. The below is the code that goes in the .aspx file

<body>
<form id="form1" runat="server">
<div id="yahooHtml" runat="Server"></div>
</form>
</body>

3. Now, in the another_domain_info.aspx.cs file create Page_Load event
and put the below code.

protected void Page_Load(object sender, EventArgs e)
{

WebRequest w = WebRequest.Create("http://www.yahoo.com");
WebResponse wr = w.GetResponse();

StreamReader r = new StreamReader (wr.GetResponseStream());

String html = r.ReadToEnd();

HtmlGenericControl DivElement = this.FindControl("yahooHtml")
as HtmlGenericControl;
DivElement.InnerHtml = html;

r.Close();
wr.Close();
}

4. Now press F5 to execute this code. You can see yahoo's home page in
the aspx file.

Basically, what happens is WebRequest object request the given url and
gets the response coming back from the server. After getting the
response we are binding the response which is html data to the div tag
kept in the .aspx file.
 
Reply With Quote
 
Mark Newmister
Guest
Posts: n/a
 
      06-27-2006
Maybe Server.Execute will help?

"Ray Booysen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> woops, forgot to mention. This is with ASP.net 1.1
>
> Ray Booysen wrote:
>> Hi all
>>
>> I have a webform with some functionality I need to use. But I need the
>> page to render first. Is there any way to do this?
>>
>> I essentially need to instanciate an instance of the page get it to
>> render without it showing on the screen and then call a method that is
>> available.
>>
>> Can this be done?
>>
>> Regards
>> Ray



 
Reply With Quote
 
Ray Booysen
Guest
Posts: n/a
 
      06-27-2006
Hi Vadivel

Thanks a ton, this is exactly what I'm looking for.

Vadivel Kumar wrote:
> Ray Booysen wrote:
>> woops, forgot to mention. This is with ASP.net 1.1
>>
>> Ray Booysen wrote:
>>> Hi all
>>>
>>> I have a webform with some functionality I need to use. But I need
>>> the page to render first. Is there any way to do this?
>>>
>>> I essentially need to instanciate an instance of the page get it to
>>> render without it showing on the screen and then call a method that
>>> is available.
>>>
>>> Can this be done?
>>>
>>> Regards
>>> Ray

>
> Hi,
>
> If i assume that you need to execute that page internally and get the ht
> ml content, then it is very much possible. In the bottom of this reply
> you can find and excerpt that calls the .aspx page using WebRequest
> object and populates the html content into Div element.
>
> In other way, if i assume that you want to execute the page just for the
> sake of doing some process and with you need to pass some parameters
> (means, you have to input some values) for the methods. Then, the only
> way is to encapsulate the class that is inherited by the page from
> another class and calling its methods to do so.
>
> But, I suggest you should keep the code that needed to be "re-used" for
> multi-purpose should be kept in different class and should be called in
> appropriate places whenever needed.
>
> Anyways, Let me know if this helps you or I am wrong in any case. And,
> check the below code excerpt as well.
>
> -
> Vadive
>
> -------
> 1. Create an ASPX page called "another_domain_info.aspx"
> 2. The below is the code that goes in the .aspx file
>
> <body>
> <form id="form1" runat="server">
> <div id="yahooHtml" runat="Server"></div>
> </form>
> </body>
>
> 3. Now, in the another_domain_info.aspx.cs file create Page_Load event
> and put the below code.
>
> protected void Page_Load(object sender, EventArgs e)
> {
>
> WebRequest w = WebRequest.Create("http://www.yahoo.com");
> WebResponse wr = w.GetResponse();
>
> StreamReader r = new StreamReader (wr.GetResponseStream());
>
> String html = r.ReadToEnd();
>
> HtmlGenericControl DivElement = this.FindControl("yahooHtml") as
> HtmlGenericControl;
> DivElement.InnerHtml = html;
>
> r.Close();
> wr.Close();
> }
>
> 4. Now press F5 to execute this code. You can see yahoo's home page in
> the aspx file.
>
> Basically, what happens is WebRequest object request the given url and
> gets the response coming back from the server. After getting the
> response we are binding the response which is html data to the div tag
> kept in the .aspx file.

 
Reply With Quote
 
Ray Booysen
Guest
Posts: n/a
 
      06-28-2006
Argh, I expected the Webrequest to be executed within the current
context, and it seems to create a new session and execute seperately.

I'm calling a page within my application. Is there any way to call the
page within the current context?

Regards
Ray

Vadivel Kumar wrote:
> Ray Booysen wrote:
>> woops, forgot to mention. This is with ASP.net 1.1
>>
>> Ray Booysen wrote:
>>> Hi all
>>>
>>> I have a webform with some functionality I need to use. But I need
>>> the page to render first. Is there any way to do this?
>>>
>>> I essentially need to instanciate an instance of the page get it to
>>> render without it showing on the screen and then call a method that
>>> is available.
>>>
>>> Can this be done?
>>>
>>> Regards
>>> Ray

>
> Hi,
>
> If i assume that you need to execute that page internally and get the ht
> ml content, then it is very much possible. In the bottom of this reply
> you can find and excerpt that calls the .aspx page using WebRequest
> object and populates the html content into Div element.
>
> In other way, if i assume that you want to execute the page just for the
> sake of doing some process and with you need to pass some parameters
> (means, you have to input some values) for the methods. Then, the only
> way is to encapsulate the class that is inherited by the page from
> another class and calling its methods to do so.
>
> But, I suggest you should keep the code that needed to be "re-used" for
> multi-purpose should be kept in different class and should be called in
> appropriate places whenever needed.
>
> Anyways, Let me know if this helps you or I am wrong in any case. And,
> check the below code excerpt as well.
>
> -
> Vadive
>
> -------
> 1. Create an ASPX page called "another_domain_info.aspx"
> 2. The below is the code that goes in the .aspx file
>
> <body>
> <form id="form1" runat="server">
> <div id="yahooHtml" runat="Server"></div>
> </form>
> </body>
>
> 3. Now, in the another_domain_info.aspx.cs file create Page_Load event
> and put the below code.
>
> protected void Page_Load(object sender, EventArgs e)
> {
>
> WebRequest w = WebRequest.Create("http://www.yahoo.com");
> WebResponse wr = w.GetResponse();
>
> StreamReader r = new StreamReader (wr.GetResponseStream());
>
> String html = r.ReadToEnd();
>
> HtmlGenericControl DivElement = this.FindControl("yahooHtml") as
> HtmlGenericControl;
> DivElement.InnerHtml = html;
>
> r.Close();
> wr.Close();
> }
>
> 4. Now press F5 to execute this code. You can see yahoo's home page in
> the aspx file.
>
> Basically, what happens is WebRequest object request the given url and
> gets the response coming back from the server. After getting the
> response we are binding the response which is html data to the div tag
> kept in the .aspx file.

 
Reply With Quote
 
Ray Booysen
Guest
Posts: n/a
 
      06-28-2006
YAY! Server.Execute was what I needed!

Ray Booysen wrote:
> Argh, I expected the Webrequest to be executed within the current
> context, and it seems to create a new session and execute seperately.
>
> I'm calling a page within my application. Is there any way to call the
> page within the current context?
>
> Regards
> Ray
>
> Vadivel Kumar wrote:
>> Ray Booysen wrote:
>>> woops, forgot to mention. This is with ASP.net 1.1
>>>
>>> Ray Booysen wrote:
>>>> Hi all
>>>>
>>>> I have a webform with some functionality I need to use. But I need
>>>> the page to render first. Is there any way to do this?
>>>>
>>>> I essentially need to instanciate an instance of the page get it to
>>>> render without it showing on the screen and then call a method that
>>>> is available.
>>>>
>>>> Can this be done?
>>>>
>>>> Regards
>>>> Ray

>>
>> Hi,
>>
>> If i assume that you need to execute that page internally and get the
>> ht ml content, then it is very much possible. In the bottom of this
>> reply you can find and excerpt that calls the .aspx page using
>> WebRequest object and populates the html content into Div element.
>>
>> In other way, if i assume that you want to execute the page just for
>> the sake of doing some process and with you need to pass some
>> parameters (means, you have to input some values) for the methods.
>> Then, the only way is to encapsulate the class that is inherited by
>> the page from another class and calling its methods to do so.
>>
>> But, I suggest you should keep the code that needed to be "re-used"
>> for multi-purpose should be kept in different class and should be
>> called in appropriate places whenever needed.
>>
>> Anyways, Let me know if this helps you or I am wrong in any case. And,
>> check the below code excerpt as well.
>>
>> -
>> Vadive
>>
>> -------
>> 1. Create an ASPX page called "another_domain_info.aspx"
>> 2. The below is the code that goes in the .aspx file
>>
>> <body>
>> <form id="form1" runat="server">
>> <div id="yahooHtml" runat="Server"></div>
>> </form>
>> </body>
>>
>> 3. Now, in the another_domain_info.aspx.cs file create Page_Load event
>> and put the below code.
>>
>> protected void Page_Load(object sender, EventArgs e)
>> {
>>
>> WebRequest w = WebRequest.Create("http://www.yahoo.com");
>> WebResponse wr = w.GetResponse();
>>
>> StreamReader r = new StreamReader (wr.GetResponseStream());
>>
>> String html = r.ReadToEnd();
>>
>> HtmlGenericControl DivElement = this.FindControl("yahooHtml")
>> as HtmlGenericControl;
>> DivElement.InnerHtml = html;
>>
>> r.Close();
>> wr.Close();
>> }
>>
>> 4. Now press F5 to execute this code. You can see yahoo's home page in
>> the aspx file.
>>
>> Basically, what happens is WebRequest object request the given url and
>> gets the response coming back from the server. After getting the
>> response we are binding the response which is html data to the div tag
>> kept in the .aspx file.

 
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
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
how does the freetextbox interact with other html elements?? =?Utf-8?B?RGljazIwMDQ=?= ASP .Net 0 11-03-2004 04:20 PM
Getting Windows Controls to Interact with Web Controls lltaylor ASP .Net 1 06-30-2004 07:16 AM
Mozilla new versions interact Franck Henry Firefox 1 05-14-2004 10:52 AM
how to interact client script within aspx page to other page functions, etc.? PLEASE!!! KathyB ASP .Net 0 07-04-2003 09:24 PM



Advertisments