Click here to Skip to main content
12,240,822 members (54,735 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET .NET C#4.0 .NET4
I have 3 controls (1 label, 1 textbox , 1 button)in my web user control page....
i have 3 forms on which button(of web user control) will perform different operations(insert, update ,delete)

how can i achieve this????

web user control page

<script runat="server">
public string LabelText
myLabel.Text = value;
public string Text
return myTextBox.Text;
public string btntext
        Button1.Text = value;
<asp:Label ID="myLabel" runat="server" Text="" Width="100" />
<asp:TextBox ID="myTextBox" runat="server" Text="" Width="200"
MaxLength="20" />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

default1 page
<%@ Register src="SmartBox.ascx" tagname="SmartBox" tagprefix="sp" %>
    <uc1:SmartBox ID="SmartBox1"  runat="server" btntext="Insert"  LabelText="ENTER:"/>

in default2 page 
<%@ Register src="SmartBox.ascx" tagname="SmartBox" tagprefix="sp" %>
    <uc1:SmartBox ID="SmartBox1" runat="server" btntext="delete"  LabelText="ENTER:"/>

how to operate opeartions of delete and insert on two forms with user control
Posted 22-Jan-13 1:42am
vinodkumarnie 25-Jan-13 5:45am
If you know the properties of get{} and set{}, you can achieve this easily in back-end code..

If you didn't get i will gave you the solution..

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

steps for creating web user control:
1.Add User Control in project Select "Web User Control" from New Item Window and name it .
2.Add following code to file .ascx
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="ucImageViewer.ascx.cs" Inherits="ucImageViewer" %>
<table border="0" cellpadding="0" cellspacing="0">
<td align="center">
<asp:Image ID="Image1" runat="server" />// using image you can use label or text as per requirement
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Original View"
OnClick="Button1_Click" />
3. add event handler and perform required operation in ascx.cs file like:
protected void Button1_Click(object sender, EventArgs e)
4.Ad peroperites if any
5.Now to display Web User Control on Web Form in
<%@ Register Src="ucControlName.ascx" TagName="somename" TagPrefix="uc" %>
Src - It specifies source of web user control.
TagPrefix - It Specifies Prefix for user control, i.e. Namespace to which it belong.
TagName - It Specifies Alias to the user control. i.e. Id to Control.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100