c# - Set Properties and create events for a user control -
i'm creating web user control in asp.net using c# in can select date calendar , display in textbox. when select date calender has displayed in textbox. need set own properties can select datetime patterns in cs codefile. example
usercontrol1.dd-mm-yyyy.
this 1 example. want datetime patterns of "en-us". when use usercontrol in page want set of properties(datetime patterns) control. please me!!!
i tried coding no use... plz review , give me solution
public partial class datecontrol : system.web.ui.usercontrol {
string dateformat; public string dateformat { { return dateformat;} set { dateformat = value; } } protected void page_load(object sender, eventargs e) { if(!page.ispostback) { pageload(); lnlbtnchangedate.visible = false; ddldateformat.visible = false; calendar.visible = false; } lblerror.visible = false; } public void pageload() { if (txtboxdate.text != "") { calendar.visible = false; } cultureinfo ci = new cultureinfo("fr-fr"); string[] format = ci.datetimeformat.getalldatetimepatterns(); foreach (string in format) { ddldateformat.items.add(i); } } protected void lnkbtnpickdate_click(object sender, eventargs e) { calendar.visible = true; lnlbtnchangedate.visible = true; ddldateformat.visible = false; } public void calendar_selectionchanged1(object sender, eventargs e) { txtboxdate.text = calendar.selecteddate.toshortdatestring(); } protected void ddldateformat_selectedindexchanged(object sender, eventargs e) { txtboxdate.text = calendar.selecteddate.tostring(ddldateformat.selectedvalue.tostring()); } protected void lnlbtnchangedate_click(object sender, eventargs e) { calendar.visible = false; if (txtboxdate.text == "") { lblerror.visible = true; } else { lblerror.visible = false; lnlbtnchangedate.visible = true; ddldateformat.visible = true; } } protected void lnkbtnclear_click(object sender, eventargs e) { txtboxdate.text = ""; calendar.visible = false; lnlbtnchangedate.visible = false; ddldateformat.visible = false; lblerror.visible = false; }
i said want set properties user control , create events that.... plz me
not sure right @ question not clear, anyway :
you create properties user controls, , assign enums them
public enum my_usercontrol_dateformats { yyyymmdd = 1, yyyymmddhh = 2, yyyymmddhhmmss = 3 }
and in setter code of properties handle logic assign date format (for example) according enum value (using switch/case)
it's 1 among many possibilities.
Comments
Post a Comment