473,395 Members | 1,458 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,395 software developers and data experts.

Catching specific controls html output after render

In the RenderControl() method I have some code which will catch the controls
HTML output. But what I'm tring to accomplish is catching only a perticular
control and its child controls. The code below catches everything.

----------------------------------------------------
string content "";

foreach(Control c in this.Controls) {
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
c.RenderControl(htw);
StringBuilder sb = sw.GetStringBuilder();
content += sb.ToString();
}
-----------------------------------------------------

The control has two placeholders each with an infiniat ammount of child
controls, lets say PlaceHolder1 and PlaceHolder2.
I would like to loop through the controls and catch all of the child
controls of PlaceHolder1 and store the output in a string. And then catch
all of the child controls of PlaceHolder2 and store the output in a
seperater string. I was able to add an if statement that checked for the
controls ID and if it was equal to one of the two PlaceHolder ID's then it
would catch the output(none). But wouldn't catch the PlaceHolders child
controls.
Any suggestions?

Thanks
Ron Vecchi
Nov 18 '05 #1
4 1257
Hi Ron,

Thank you for posting to the MSDN newsgroups.

I am interested in this issue and researching on it now. More time is
needed. Thank you for your understanding.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #2
Hi Ron,

I am trying to reproduce the problem on my side. Would you please tell me
how to reproduce it step by step? I certainly appreciate your time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #3
Thanks Jacob for your help,
I think I have it. Im not sure what I was doing before but I am catching
the control(and child controls now)
I supressed the base.RenderChildren
And am only writing out the content of placeholder 1
The I allow the content of any other controls written.

This is exactly what I was trying to do. I can't figur out what I was tring
before because I had checked for the PlaceHolders ID. Error on my part
somewhere anyways.

Thanks for your great support!
My code for override RenderChildren is below.
-------------------------------------------
string content1 = "";
string content2 = "";
string otherControls = "";

foreach(Control c in this.Controls) {
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
c.RenderControl(htw);
StringBuilder sb = sw.GetStringBuilder();

if(c.ID=="PlaceHolder1"){
content1 += sb.ToString();
}
else if(c.ID=="PlaceHolder2"){
content2 += sb.ToString();
}
else{
otherControls += sb.ToString();
}
}
writer.Write(content1);
writer.Write(otherControls);
//base.RenderChildren(writer);





"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:qT**************@cpmsftngxa07.phx.gbl...
Hi Ron,

I am trying to reproduce the problem on my side. Would you please tell me
how to reproduce it step by step? I certainly appreciate your time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #4
Hi Ron,

I am very glad to know that the problem is resolved.

If you have any more concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #5

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

Similar topics

4
by: Ron Vecchi | last post by:
I have a custom control which has a child control (PlaceHolder) The placeholder will have any number of child controls added to it. I would like to catch the rendered content of the placeholder...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
2
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the...
4
by: Alexandre Soares | last post by:
Hi, If I make a control that derives from panel, how can I persist the state of the controls that are inside the panel when it is not rendered (visible = false)? The reason for this is that...
4
by: clintonG | last post by:
Technically speaking, this issue is not about modifying the HTML generated by server controls but preceding the HTML generated by server controls with an HTML control generated on the basis of the...
3
by: Qwert | last post by:
Heya, I have a cusom control: Imports System.ComponentModel Imports System.Web.UI <DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl5 runat=server></{0}:WebCustomControl5>")>...
3
by: msnews.microsoft.com | last post by:
Hello All, I am trying to write Web Controls and in most of the samples I came across, I am seeing the following function where a HTML string is written to create HTML Controls. ///...
3
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.