.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

how create user control in asp.net

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

how create user control in asp.net 

View Complete Post

More Related Resource Links

how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

Best way to create a collection of User Control objects?

Hi, I'm completely new to WPF (this week) and still grasping C# and .net as a whole. I've created a User Control which I need to add (and be able to remove) multiple instances of into a vertical list. I've so far stuck this in a Listbox although I might change this later when I'm more comfortable. So when I add the object I've created as a ListBox item it displays fine, but my issue is I need to able to delete items and add items and have those items auto update etc - so I'm guessing the WPF way to do things is to build a collection and have it bind to the list box. My question is this, what is the best type of collection to hold such objects. I've tried an Observablecollection so that I can monitor changes but when I give it a.Itemsource = Observablecollection it just presents me with a list of <Collection>. Anyone any ideas?

go back to Create User Step on CreateUserWizard control



I'm using a CreateUserWizard do add users to a web app. Everything is working great, but on thing... the Complete Step :-/

I don't need that extra step, and more, i'm using this control as an option where the administrator of the application adds his trusted users to the site. So, its part of a web form that has a list of users on one side and the CreateUserWizard on the other.

What i tried to do, and was unsuccessful, was to change the ActiveStepIndex back to 0 then the user creation was completed, but this didn't work. The Complete Step still appears. Also, i added this to the continue button event and it did nothing either: CreateUserWizard1.ActiveStepIndex = 0;

Is there any way i can "hide" this step? If not, is there a way to go back to the Create User Step when i click the Continue button in the Complete Step?


how to create dropdownlist user control(acsx) and fill from database


how to create dropdownlist user control(acsx) and fill from database

Need to create a customizable user control



I am planning to write a user control but need to know if anyone has ever read any good article on how to write a usercontrol. My requirement is to create a kind of panel control that can have option buttons, checkboxes and a gridview control. I already have created this control but everything is hardcoded (styles, other properties) in user control. I want to expose them to the user so that he can change the appearance and the placement of the controls by himself. Also, I want users to consume this control something like

<uc1: MyPanel runat="server">
  <panelgridview property1="" property2="" datasource="">...</panelgridview>
</uc1: MyPanel>

Not sure how to make the those sub tags for a usercontrol. Any pointers or help is much appreciated.

Create user control fields based on bound properties



I am creating a user control that I would like to be able to generate the form entry fields based on what custom data object the form is bound to. Basically, I have a drop-down box that allows the user to pick what type of data object they are working with (user, address, etc.) That choice will bind the user control to the related data object. No big deal there. I am stuck, however, on how to generate the form fields based on the properties of the object. I feel like I have seen examples of this in WPF but am not able to find them now. All form fields will be simple label, textbox combinations in a stackpanel.

I know more detial will probably be required. Let me know what specifically you would like to know. Any help of direction is greatly appreciated.



create custom application page with a ribbon and user control webpart


i am in stress how to start this what should be the first step

i want to create custom application page with a ribbon and some user
control web part to show document item properties.

Please help me regarding this


thanks in advance 



wasikhan junior software ENG

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2008


I am having problems with a user control. I want my solution to have a separate project for holding my user controls.

The main project can get a reference to this user control project and can import this user control dll into my main project. 

Thanks in advance,

Dheeraj Mittal


Multiple Instances of User Control


I have a user control that I place on a page severl times.  When I make a selection on a ddl in one one control the SelectedIndexChanged event fires for all the control on the page for that ddl.  So I get duplication of an insert that I do.  Is there a way to make sure these events are isolated so this doesn't happen.


form feild hints are not displaying for textboxses inside create user wizard?



I'm using following JS code to display input hint box besides the textbox whenever that asp.net textbox receives focus. 

I'm doing this for a registration form and all of the textboxes are inside the asp.net create user wizard control.

<script type="text/javascript">
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("TextBox");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";

create user wizard login error message dont show in a message box?




i am using create user wizard and capturing other information within content template when a new user

registers. Some of the textboxes are binded to required field validators.


there is a validation control on the page and ShowMessage box is True.

If they dont complete some of the text boxes then the message box pops Up with the error message.

It does not however include information errors like "User already exists" or Email address already exists

from the create user wizard membership  UserName and Password Textboxes


is it possilbe to hook all of these up so I get one message box with all errors including membership ones?




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

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Create a user friendly pop up window


Hello friends I am new to asp.net programming. While working with windows form(windows application) i have created a window for editing purpose(just like popup window ) which contains three bounded dropdown list a button and a gridview. After making selections from the drop down when we press button the corresponding result should display in a grid.After that when you click on the grid row it will load the corresponding datas in my form. i want to create such control in asp.net . i have to use jquery or ajax.And this pop up window i have to use more than twenty times in my application.am using VS2008 ASP.NET and C# 3.5 . Plese suggest me what to do. Thanks in advance

OnItemCommand not firing in Templated User Control


I have a templated user control with single instance template attribute. It works great for everything except the following scenario:


    <asp:UpdatePanel ID="upDirectoryBrowser" runat="server">
        <asp:AsyncPostBackTrigger ControlID="fsBrowser" EventName="FolderSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="FileSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="LinkSelected" />
        <table width="100%">
                <td style="width: 230px;">                        
                    <ntc:FolderSelector ID="fsBrowser" runat="server" OnFolderSelected="fsBrowser_FolderSelected"
                    OnControlException="fsBrowser_ControlException"  /> 
                    <ntc:FileSelector ID="flsBrowser" runat="server" OnFileSelected="flsBrowser_FileSelected"
                    OnControlException="fsBrowser_ControlException" O

"Type ASP.x is not defined" error for dynamic user control when publishing updateable


I have a user control (ContainerCtrl) which programmatically instantiates another user control (SimpleCtrl) in OnLoad. It builds and runs fine, but when I publish it I get the error "error BC30002: Type 'ASP.SimpleCtrl' is not defined." (If I publish without the "updateable" option there's no error, but I need the site to be updateable.)

I assume this has to do with the particulars of how the assembly(ies) are built for the different compiler options. My question is, how can I get it to work properly for "updateable" publishing?

VS 2008 / .NET 3.5 sp1

The code follows (web.config is the default from Visual Studio).

Many thanks, Dave


<%@ Control Language="VB" ClassName="SimpleCtrl" CodeFile="SimpleCtrl.ascx.vb" Inherits="_SimpleCtrl" %>

    Simple control


Partial Class _SimpleCtrl
    Inherits UserControl

    'Nothing to see here.

End Class


<%@ Control Language="VB" CodeFile="ContainerCtrl.ascx.vb" Inherits="_ContainerCtrl"

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