473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Off-Page Rendering of Server Controls with events

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

Feb 21 '07 #1
1 1081
On Feb 21, 9:15 am, "Bob Jones" <goodold...@gmail.comwrote:
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

Feb 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Frank | last post by:
Whats best : register_globals ON ? OR register_globals OFF ? I currently use: $_POST
7
by: Agent Mulder | last post by:
Hi group, I thought it might be a good idea to come up with a tagging system for off-topic posts, Borland style. So instead of the 'generic' Soundcard crashed under VC6.0 we would have
2
by: Alexander Schmidt | last post by:
Hi, I am not very familiar with C++ programming, so before I do a dirty hack I ask for a more elegant solution (but only the usage of STL is allowed, no special libs). So I need to read a file...
33
by: Chris Croughton | last post by:
I notice the real reason for not posting "off-topic" here is that the result will be a long thread on whether the matter is off-topic or not -- caused by the very people who claim that they don't...
5
by: Andreas Müller | last post by:
Hi! I've been looking for a way to log off another user from Windows XP, that is to terminate his session without having to shutdown Windows. My goal is to write a service (preferrably running...
4
by: no_spam_for_gman | last post by:
Hi, I can turn off autocommit within the command window but I cannot figure out how to turn it off when you are in the IBM DB2 Command Line Processor. Does anybody knows how? By the way I mean...
6
by: Frank Rizzo | last post by:
I have the following situation: 1. Application X1 runs under a regular user account (this user is also the currently logged on user). 2. Application X1 kicks off Application X2 using an...
8
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
0
by: scooby dooby | last post by:
Hi All, I need to write a script for windows,which has the requirements as below. 1,It should log out the particuler user from windows at a particuler time ,say 6 o'clock in the evening...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.