Click here to Skip to main content
12,756,624 members (32,414 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
{
set
{
myLabel.Text = value;
}
}
public string Text
{
get
{
return myTextBox.Text;
}
}
public string btntext
{
    set
    {
        Button1.Text = value;
    }
}
</script>
<p>
<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" />
</p>




default1 page
<%@ Register src="SmartBox.ascx" tagname="SmartBox" tagprefix="sp" %>


how to operate opeartions of delete and insert on two forms with user control
Posted 22-Jan-13 1:42am
Comments
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
 
good
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">
<tr>
<td align="center">
<asp:Image ID="Image1" runat="server" />// using image you can use label or text as per requirement
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Original View"
OnClick="Button1_Click" />
</td>
</tr>
</table>
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 asp.net:
<%@ Register Src="ucControlName.ascx" TagName="somename" TagPrefix="uc" %>
  Permalink  

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.170217.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2017
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