Click here to Skip to main content
15,917,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I have one aspx page with Textbox, radiobutton, dropdownlist and button. same controls or same form i want in another two pages. so im planning to create the User control but Im not able to find that controls.

Can some one please let me know how to do this in User control and handle its events like dropdownlist selected inedex changed, textbox textchanged events and all..?

Thanks in advance..

Madan
Posted
Updated 22-Apr-13 22:09pm
v2

what is this question ? clarify instead of copy pasting it
 
Share this answer
 
Hi,
Once you create a user control,Create a getter and setter of each control on that user control code behind file.

here my user control lets say demoControl.ascx in that,

Suppose 1 label control is there,
C#
<asp:label id="lblName" runat="server/" xmlns:asp="#unknown"></asp:label>


& in demoControl.ascx.cs ,

C#
public Label LBL_Name
        {
            get
            {
                return lblName;
            }
            set
            {
                lblName = value;
            }
        }



Calling that user control in your required page.
C#
<![CDATA[<%@ Register TagPrefix="demoTest" TagName="demoTest" Src="<User Control Path>" %>]]>


C#
<demotest:demotest id="ucDemoControl" title="DemoControl" runat="server" xmlns:demotest="#unknown" />



& In codebehind,


C#
ucDemoControl.LBL_Name.text="Code Project";
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900