Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Off-Page Rendering of Server Controls with events

Reply
Thread Tools

Off-Page Rendering of Server Controls with events

 
 
Bob Jones
Guest
Posts: n/a
 
      02-21-2007
Hey everyone. I have another problem. I have an aspx web page that
contains an event. When the event is fired it creates an instance of a
server control that contains an event of its own. I would like to be
able to render the contents of the server control (HTML w/ event
JavaScript code) and store it for later use.

My problem lies when I call the MyControl.RenderControl method. It
returns valid HTML but does not contain the event code since the
control has not been added to any page object.

Here is what I have tried:

HtmlForm hForm = new System.Web.UI.HtmlControls.HtmlForm();
hForm.Attributes.Add("runat", "server");
hForm.Controls.Add(spWC);

Page p = new Page();
p.Controls.Add(hForm);
p.RenderControl(hWriter); // <-- error here stating that no Response
object available.

I do understand that I am getting a "Response not available" error
because there is no context associated with the newly created page
object. Any ideas as to how I can achieve the results I am looking
for?

-David

 
Reply With Quote
 
 
 
 
Bob Jones
Guest
Posts: n/a
 
      02-22-2007
On Feb 21, 9:15 am, "Bob Jones" <goodold...@gmail.com> wrote:
> Hey everyone. I have another problem. I have an aspx web page that
> contains an event. When the event is fired it creates an instance of a
> server control that contains an event of its own. I would like to be
> able to render the contents of the server control (HTML w/ event
> JavaScript code) and store it for later use.
>
> My problem lies when I call the MyControl.RenderControl method. It
> returns valid HTML but does not contain the event code since the
> control has not been added to any page object.
>
> Here is what I have tried:
>
> HtmlForm hForm = new System.Web.UI.HtmlControls.HtmlForm();
> hForm.Attributes.Add("runat", "server");
> hForm.Controls.Add(spWC);
>
> Page p = new Page();
> p.Controls.Add(hForm);
> p.RenderControl(hWriter); // <-- error here stating that no Response
> object available.
>
> I do understand that I am getting a "Response not available" error
> because there is no context associated with the newly created page
> object. Any ideas as to how I can achieve the results I am looking
> for?
>
> -David


sp, nobody on here has any idea on how to get this working? Or if it's
even possible

 
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
dynamically adding controls with events (but events are not firing) SevDer ASP .Net 2 11-13-2007 06:33 AM
runtime events that generate other controls and events newbye ASP .Net 0 07-06-2006 06:27 PM
IE6 SP1 rendering vs IE6 SP2 rendering Peter Mount HTML 4 01-31-2006 08:01 AM
Rendering Server Controls in literal text =?Utf-8?B?Sm9l?= ASP .Net 14 10-24-2005 06:21 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57