create a web user control and used on web form?, and How to get value of ddl, calendar(used on ascx) on main page

173 views Asked by At

i'm new and i want to create a web user control and used on web form?, and How to get value of ddl, and calendar(used on ascx) on main page. work i've done, i've created web user control and also used on web form and out put also has been show but the next thing which i want that the value of ddl or calendar used on ascx page should b get on main page i mean to say which value i'll choose from ddl or calendar should b get on main page i'm waiting for code help plz .ascx page

            <asp:TextBox ID="txtData" runat="server"></asp:TextBox>
        <br />
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <br />
            <asp:Label ID="lblData" runat="server" ForeColor="Red">
        </asp:Label>
        <br />
            <asp:Calendar ID="Calendar1" runat="server" BackColor="Beige" OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>
        <br />
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Red"></asp:Label>
        <br />
        <asp:DropDownList ID="ddlthings" OnSelectedIndexChanged="ddlthings_SelectedIndexChanged" runat="server">
            <asp:ListItem> Apple</asp:ListItem>
            <asp:ListItem> Banana</asp:ListItem>
            <asp:ListItem> Mango</asp:ListItem>
            <asp:ListItem> Grapes</asp:ListItem>
        </asp:DropDownList>
        <asp:Label ID="lblthings" ForeColor="Red" runat="server"></asp:Label>

and .aspx page is <%@ Register src="CalendarUserControl.ascx" tagname="CalendarUserControl" tagprefix="uc1" %> ;

1

There are 1 answers

0
Saleh Rezaei On

you need to declare public fields in user control, then you can set the values inside the control and have them on main page.