473,769 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetStringBui lder();
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 1275
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.RenderChil dren
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.GetStringBui lder();

if(c.ID=="Place Holder1"){
content1 += sb.ToString();
}
else if(c.ID=="Place Holder2"){
content2 += sb.ToString();
}
else{
otherControls += sb.ToString();
}
}
writer.Write(co ntent1);
writer.Write(ot herControls);
//base.RenderChil dren(writer);





"Jacob Yang [MSFT]" <ji***@online.m icrosoft.com> wrote in message
news:qT******** ******@cpmsftng xa07.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
1382
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 child control prior to it being sent to the browser and wrap all the HTML content in document.write('') JS statements. I'm kind of lost on how to capture the raw HTML content. (for starters :) Any suggestions
3
2651
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 and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
2
5005
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 Page Load of a main ASPX page. Now if we debug the MyTextBox, we find the order of events like so (during a Posback, of course): OnInit -> OnLoad -> LoadPostData. My question is why does the LoadPostData occur *after* the OnLoad instead of...
4
1792
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 I'm making a custom user control that derives from the Panel class. In the render method, I render some stuff and then I do base.render if the panel is to be visible. If it's to be hidden, I don't render it, but when I render it again, the controls...
4
1976
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 type and the context of the server control itself. Clear as mud? :-) Consider the following server control... <asp:textbox id="MemberEmail" runat="server" ></asp:textbox> TextBox renders at run-time as an HTML control... <input...
3
1779
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>")> Public Class WebCustomControl5 Inherits System.Web.UI.WebControls.WebControl Dim _text As String
3
1506
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. /// <summary> /// Render this control to the output parameter specified.
3
2563
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 consituent control caused a postback. for example a have a consituent controls with two buttons on it "button1" and "button2" I have registered my control for postbacks using
4
2468
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 suspect some permissions problem. I'm running VS.NET 2008 in Vista. Symptoms and observations: * ASP.NET's native ImageMap and Image controls work just fine and provide a design-time preview of images that are referenced via the ImageUrl property *...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.