Introduction
In this blog you will learn how to create a
Web user control in asp.net4.
Step 1: Open visual studio
Take new web applicarion
Step 2: Add Web user control
Step 3: Add control
webusercontrol1.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"
Inherits="article.WebUserControl1" %>
<asp:TextBox ID="txtvalue" runat="server"></asp:TextBox>
<asp:Button ID="btnClick" runat="server" OnClick="btnClick_Event" Text="Click" />
Step 4: Create an event,
webusercontrol1.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace article
{
public delegate void click(String str);
public partial class WebUserControl1 : System.Web.UI.UserControl
{
public event click clickEvent;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnClick_Event(object sender, EventArgs e)
{
clickEvent(txtvalue.Text);
}
}
}
Step 5: Rebuild our application then add a web form and drag and drop
created user control to our new web form web form aspx pge webform.aspx

aashish mangalPosted Jul 12, 2014, 3:02 AM
can i use multiple user control in single aspx page. like multiple dropdownbox, datetimepicker usercontrol in single aspx page