c# - How to access value of usercontrol in asp.net -



c# - How to access value of usercontrol in asp.net -

i have web application assigns time duration students in day. kind of scheduler.

so have user command timeperiod , command loaded dynamically on web page.

but number of user command on page varies have user code dynamically creates list of user control.

for illustration purpose have set i value 2, varies looks this:

for(int i=0;i<2;i++) { timeperiod ib = (timeperiod)loadcontrol("timeperiod.ascx"); //ib.rightarrowimgurl = "~/images/wcm-circle-arrow-button.png"; span_templist.controls.add(ib); }

when user done making changes time days. i.e. in user command on page.

the page has button takes changes database.

but problem arises here how access values of these text boxes values page has been rendered html.

this user command code:---

<%@ command language="c#" autoeventwireup="true" codebehind="timeperiod.ascx.cs" inherits="classmanagment.timeperiod" %> <div> <asp:textbox id="time3" size="10" value="08:00" runat="server"></asp:textbox><asp:textbox id="time4" size="10" value="09:00" runat="server"></asp:textbox> </div>

code behind of usercontrol:--------

public partial class timeperiod : system.web.ui.usercontrol { protected global::system.web.ui.webcontrols.textbox time3 = new system.web.ui.webcontrols.textbox(); protected global::system.web.ui.webcontrols.textbox time4 = new system.web.ui.webcontrols.textbox(); public string timefrom { { homecoming time3.text; } set { time3.text = value; } } public string timeto { { homecoming time4.text; } set { time4.text = value; } } }

how can access values of usercontrol ?

like so:

timeperiod ib = (timeperiod)loadcontrol("timeperiod.ascx"); string timeto = ib.timeto; string timefrom = ib.timefrom;

c# asp.net user-controls

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -