How to put a 3rd party server control inside a custom server control in ASP.Net?

You'll want to create a CompositeControl This allows you to easily add HTML markup and controls using an override of CreateChildControls and not have to think about too much else Some sample code: using System. ComponentModel; using System.Web. UI; using System.Web.UI.

HtmlControls; using System.Web.UI. WebControls; namespace TestServerControls { DefaultProperty("Text") ToolboxData("") public class GridWithHeader : CompositeControl { private readonly GridView _grid = new GridView(); private readonly HtmlGenericControl _header = new HtmlGenericControl("h1"); public string Text { get { return _header. InnerHtml; } set { _header.

InnerHtml = value; } } protected override void CreateChildControls() { Controls. Add(_header); Controls. Add(_grid); } } }.

You'll want to create a CompositeControl. This allows you to easily add HTML markup and controls using an override of CreateChildControls and not have to think about too much else. Some sample code: using System.

ComponentModel; using System.Web. UI; using System.Web.UI. HtmlControls; using System.Web.UI.

WebControls; namespace TestServerControls { DefaultProperty("Text") ToolboxData("") public class GridWithHeader : CompositeControl { private readonly GridView _grid = new GridView(); private readonly HtmlGenericControl _header = new HtmlGenericControl("h1"); public string Text { get { return _header. InnerHtml; } set { _header. InnerHtml = value; } } protected override void CreateChildControls() { Controls.

Add(_header); Controls. Add(_grid); } } }.

– Jeremy Child Jul 10 at 7:11 I'm just researching composite controls at the moment - didn't know they existed. – Jeremy Child Jul 10 at 7:14 Thankyou again. I was able to use the CompositeDataBoundControl do achieve the desired result.

I can instantiate the 3rd party controls in the CreateChildControls() and then Render() them based on HtmlTextWriter code and of course controlName.RenderControl(). Many thanks! – Jeremy Child Jul 10 at 11:02.

You should create a User Control (an ASCX file), which can contain other nested controls and markup.

The problem is there are too many various ways to display the data and the layout and amount of items changes are per the database and user account. – Jeremy Child Jul 10 at 7:12.

I am using Telerik ASP.Net Ajax controls (theoretically shouldn't matter who makes the 3rd party control). I would like to create my own custom server control (not user control) that has my own predefined HTML output but also includes a Telerik DatePicker. Since the Telerik DatePicker is another server control what is the correct procedure to place a server control into my custom server control.

My understanding is that server controls work by writing html output. How can I write the output of another control that I instantiate in the Render method and still retain the original controls individual lifecycle. My own custom server control that contains many 3rd party controls (ie.

Thanks to @Sumo for pointing me into the direction of the Composite control. Documentation is available here. I was able to solve the issue by creating a control that inherits CompositeDataBoundControl.

Then databinding my datasource, calculating how many custom controls needed, placing them into an ArrayList and instantiating them correctly (with their own lifecycle in CreateChildControls()). I was then able to render each control in the ArrayList of DatePicker in the Render() method by invoking the ArrayList index that has not been rendered yet. Its a dirty solution at the moment but It works for my testing purposes.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions