473,408 Members | 2,009 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,408 software developers and data experts.

adding a XML control to a web custom control

I want to create a web custom control (not a user web control) that I can
add a XML translation control into, how would I do this? I am using the web
custom control as a template that I can add to the page, but it depends on
other Web Form controls inside it but I do not know how to add the other web
form controls such as a XML web form control into this programatticly
created control. thanks
Nov 18 '05 #1
2 1460
"Brian Henry" <br**********@newsgroups.nospam> wrote in message news:O3**************@TK2MSFTNGP09.phx.gbl...
I want to create a web custom control (not a user web control) that I can
add a XML translation control into, how would I do this?


So you've created this WebCustomControl1 type from the default web
custom control project, right? Now you want to add an Xml web control
into it (or perhaps several Xml web controls into it). OK, two steps.

In your control's OnInit override (or this can also be done externally
from the Page_Init event handler) you need to create an instance of
the Xml web control and add it to the child Controls collection of the
WebCustomControl1 class.

e.g.,

protected override void OnInit( EventArgs e)
{
// Always call base class's OnInit( ) in case it does anything.
base.OnInit( e);

// Create an Xml control.
System.Web.UI.WebControls.Xml xmlControl1 = new Xml( );

// Set some properties on it; in this case my XML is really xHTML so
// it'll show up in the browser w/o too much hassle.
xmlControl1.ID = "XmlControl1";
xmlControl1.DocumentContent = "<span style='color:red;'>text</span>";
xmlControl1.TransformSource = "./IdentityTransform.xsl";

// Add the Xml control as one of this control's children.
this.Controls.Add( xmlControl1);
}

Next step is that when the ASP.NET Framework tells WebCustomControl1
to render itself, WebCustomControl1 needs to tell any child controls that they
should render themselves.

protected override void Render(HtmlTextWriter output)
{
// This line is generated automatically by the Code Wiz.
output.Write( Text);

// Render all child controls to this HtmlTextWriter.
this.RenderChildren( output);
}

Now you should be set to go. The technique is known as "composite controls,"
if you have further questions about them.
Derek Harmon
Nov 18 '05 #2
thanks!

"Derek Harmon" <lo*******@msn.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl...
I want to create a web custom control (not a user web control) that I can
add a XML translation control into, how would I do this?


So you've created this WebCustomControl1 type from the default web
custom control project, right? Now you want to add an Xml web control
into it (or perhaps several Xml web controls into it). OK, two steps.

In your control's OnInit override (or this can also be done externally
from the Page_Init event handler) you need to create an instance of
the Xml web control and add it to the child Controls collection of the
WebCustomControl1 class.

e.g.,

protected override void OnInit( EventArgs e)
{
// Always call base class's OnInit( ) in case it does anything.
base.OnInit( e);

// Create an Xml control.
System.Web.UI.WebControls.Xml xmlControl1 = new Xml( );

// Set some properties on it; in this case my XML is really xHTML
so
// it'll show up in the browser w/o too much hassle.
xmlControl1.ID = "XmlControl1";
xmlControl1.DocumentContent = "<span
style='color:red;'>text</span>";
xmlControl1.TransformSource = "./IdentityTransform.xsl";

// Add the Xml control as one of this control's children.
this.Controls.Add( xmlControl1);
}

Next step is that when the ASP.NET Framework tells WebCustomControl1
to render itself, WebCustomControl1 needs to tell any child controls that
they
should render themselves.

protected override void Render(HtmlTextWriter output)
{
// This line is generated automatically by the Code Wiz.
output.Write( Text);

// Render all child controls to this HtmlTextWriter.
this.RenderChildren( output);
}

Now you should be set to go. The technique is known as "composite
controls,"
if you have further questions about them.
Derek Harmon

Nov 18 '05 #3

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

Similar topics

9
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
2
by: Stephen Lambie | last post by:
Hi, I want to develop a custom checkbox. I want to use the existing checkbox in a custom control where I use the disabled state as a third state. I need to be able to detect mouse or click...
0
by: sonic | last post by:
hello, I have this custom datagrid control, that inherits from DataGrid. In addition to datagrid, I am adding a "status" table under it, and another html button, which will trigger a new row. ...
18
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom...
5
by: Web Team | last post by:
Hi All, Can someone please explain how I go about adding a control (Say for example a panel) to a custom web control. I've tried this: Protected Overrides Sub Render(ByVal output As...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
3
by: Jonathan Wood | last post by:
I could really use some help on this. First of all, I want to create a Web control where I render the control completely from scratch based on information from a database. In the book...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
12
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.