.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

A composite control with a listbox

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net

hello friends,

I need to create a composite control with a listbox.The selected item should be displayed on a textbox and need to edit and delete that selected item by clicking on 2 buttons edit and delete.Also another button to add item to the listbox.Items will be binded from the database as reqiured for the application.

How will create this composite control using asp.net server control?please tell me the code in C#. 

View Complete Post

More Related Resource Links

Composite Control which contains arbitrary content defined in .aspx of parent and thier ViewState


I want to write own control which can contain other. And I want to define content of the control in the .aspx file where the control is defined. I have written such control. But now I have issue with ViewState of inner controls of my control. The following samle illustrates the issue: I defined two asp:DropDownList ID="ddl1" and ID="ddl2" One of them is inside of my control and other is outside. When posback is occurred asp:DropDownList ID="ddl1 loses state and becomes empty. How to say ASP.net to store state of inner controls defined by this way?


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" Inherits="DynamicControls.Controls.MyControl" %>

<div class="box">
    <div class="Header-Left">
        <div class="Header-Right">
            My Control
    <div class="Content">
        <asp:PlaceHolder ID="contentPlace" runat="Server" />

video tutorial link for composite and rendered custom server control


hii all

i am new to technology so go easy on this post

according to what i read from web there are 3 type of custom server controls

1 superclass

2 composite

3 rendered

i found video tutorial for superclass custom server control but couldnt find video tutials for other 2.

please forward me link for composite and rendered custom server controls video tutorial  

require Video tutorial for Composite server control and rendered server control


hi guys

i am new to forum and technology so please go easy

according to what i read from web there 3 types of custom server controls

1. composite



i found video tutorial to create and use superclass custom control in your project (extending dropdown control functionality)

i am trying to search video tutorial for other 2 types .please help me.

Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Composite control: How to bubble a textbox's TextChanged event?


I've created a composite control that contains several controls, including a textbox. I'm trying to expose the TextChanged event of the textbox as an event on the composite control. I understand that events can be bubbled up the control hierarchy and handled at a higher level, which I've attempted to do, but I can't get the bubbled event to fire. When I drop the control on an aspx I can see the TextChanged event, I can subscribe to the event, but nothing ever happens. Any suggestions? Here is what I think is the relevant code:

// My event
private static readonly object EventTextChanged = new object();

//Handle the bubbled event
EventHandler textChangedHandler = (EventHandler)Events[EventTextChanged];

protected override bool OnBubbleEvent(object source, EventArgs e) 
    bool handled = false;

Localization not working in class library (composite control)



I have a class library called WEM.portal which used Resource files to localise text in my composite controls.

I store my resource files (eg MyResourceFile1.resx) in App_GlobalResources folder and then refer to them using

MyLabel1.text = My.Resources.MyResourceFile1.MyResourceKey1

This is all working ok until I create seperate files for each language such as MyResourceFile1.FR-fr.resx.

I have implemented this throughout my other web applications but the Class Library doesnt seem to want to work the same way

When I load the page it correctly showes the resourced keys which I have done through the web application BUT the resource keys in the composite controls does not seem to pick up the culture code.

Am I missing something stupid. Ive tried

  • changing the Build Action on the resource file to Content and Custom tool to GlobalResourceProxyGenerator
  • Creating a resourceManager but to no avail


User Control as Composite Control Property


I have a composite control (Called Dialog) which has a property "ContentControl"

At design time, I'd like this property to bind to a user control that is on the page.

When I add the items in the designer, the designer loads as expected.

However, when I try to run the web page, I get the following error:

Parser Error Message: Cannot create an object of type 'System.Web.UI.UserControl' from its string representation 'EditTerm1' for the 'ContentControl' property.

Please let me know if there is another way to bind a user control as a property of a composite control.


Designer Code:


	<cc1:Dialog ID="Dialog1" runat="server" Buttons="SaveCancel" 
Title="Edit Term" ContentControl="EditTerm1" />

Composite Control: Load Script at bottom?

Is there a way to have an embedded .js file load at the bottom of my page?....I can load it into the header quite easily, but I want it at the bottom :)Regards,Steve

Anyone know about DataPager in a composite control




I'm trying to use a datapager inside a composite control which references a listview inside the same composite control. Does anyone have experience with doing this as I believe I've set everything up but its not being displayed and not affecting the listView

ScriptManager in Composite Control


Hello Frnds

Can anybody tell me how can i access ScriptManager in my Composite Control?

I do have reference of system.web in my project but when i type System.Web.UI.

i am not able to get reference of ScriptManager afeter UI.

The reason for doing this is that i have a composite control which is registering some client script on OnPreRender event.

this control works fine when placed on web page without update panel but gives error "object expected" when placed in an update panel

i am registering client script as follows 

this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test" + this.ClientID, script.ToString());
when i search on google i found that i should register it like this 
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "alert('Data successfully insert into database');", true);

but i am not getting the reference of

can anybody help me to get rid of this problem.

Listbox control display property


Iam using vb.net 2.0. I have implimented  Autocomplete textbox using  textbox and listbox.These are part of grid view controls. 

If i enter data in 1st row textbox the suggestions listbox  box it is coming in between the 1 st and 2nd row of grid.So alignment is getting disturbed. How can i display the suggestions list box over the second row of grid.

I have tried chaging the display property of listbox..but no change in display..i think some other property is obveriding this.


Please help me in this.

Thanks in Advance,


How to create a server control with a listbox and dynamic control using asp.net server control in C#


Hello friends,

I need to create a reusable custom control,which is like a form containing a listbox and some fields.The fields can be either textbox or  combobox as needed for different applications,which can be selected on the property of the form onwhich page that i am using it,also i needed to specify the number of fields in that property.And also need place 3 buttons below for edit and delete the selected item in the listbox and a button to save.Data will be binded from the database as needed for different applications. Please tell me with code how to create it using asp.net server control in C#.

Thanks in advance,


Composite control in Visual Studio Toolbox


Hi Friends,

I have developed a composite control in framework 2.0. I want when I add reference assembly(.dll) of composite control in any other project, it should automatically be added into visual studio toolbox so that I can drag-n-drop it any time. Currently I need to manually add control from Visual Studio > Toolbox > Choose Items.

Any solution?


refresh listbox on updatepanel ajax control tool kit


Hi all, 

i have a dropdownlist and a listbox inside an update panel. I populate the listbox with a selected value of the dropdownlist and works ok. The problem is when delete an item from the listbox because does not the refresh of the listview and still to watch me the deleted item. 

how can i do the refresh?

pd: i am using framework 2.0

thx in advance!

How To : Add a ListBox Win form control to a asp.net .aspx page


Here is my requirement:

Do File upload without fileupload asp.net control, instead do following:

1) 'drag and drop' of file (attachment) from windows explorer to .aspx page

2) 'Copy / Paste'  - in a .aspx

What I can think of is doing it by creating a 'Windows ListBox control'.dll and calling it in aspx page with


Is there any better solution out there?

Page Life Cycle and custom composite server control life cycle



We are creating a composite server control. It will have few other controls. I am confused where exactly to write the code ie in which event. Is page life cycle and control life cycle follow the same event order?

Could any one please suggest or post articles on this.

Thank You

Extending a ListBox Control - How to make the extended type require the listbox items implement a ch


I am working on a drag and droppable timeline control, and I am making decent progress.  What I have so far will work decently enough with MVVM design patterns, but I am inexperienced with this kind of advanced control extending so I am sure that some of my methods are crude at best.

I have an extended content presenter control that I want to ensure is what is actually used inside my specialized listbox.  Right now I do the following:

<DataTemplate x:Key="TempTemplate" DataType="{x:Type local:TempDataType}">

			<tt:TimeLineItemControl StartTime="{Binding Path=StartTime}
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend