c# - Instead of making an if() for each control type, is there a cast that will allow me to dynamically set the type of control? -
I am running through my controls on this web page again and when to modify a piece of data data I am disabling other controls on the page, such controls include textboxes, listboxes and buttons. All of these controls, so there was a way to just set its properties universal data type cast control of any kind and capable then I was thinking
protected void DisableSQRcontrols (Property Control page) {foreach (Control Ctrl in Page Ctrl.Controls) if (ctrl is text box) ((text box) ctrl). Competent = false; And if (ctrl button is) ((button) ctrl). Enabled = false; And if (ctrl listbox is) ((listbox ctrl). Enabled = false; And if (ctrl.Controls.Count> 0) DisableSQRcontrols (ctrl); }
I
protected void disabled DisablesSQRcontrols (Control page) {foreach (page control Ctrl.Controls Ctrl) to change the top like some Want to If ((ctrl is text box) || (ctrl is button) || (ctrl is listbox)) ((universal controlcode ctrl). Competent = false; And if (ctrl.Controls.Count> 0) DisableSQRcontrols (ctrl); }
After
Yes, most are inheriting Webcontrol
, Such as:
system. Web. UI. WebControl .BasedataBound Control System Web. UI. WebControl .Begenditlist System Web. UI. WebControl Button system Web. UI. Web Control Calendar system Web.UI.WebControls.CheckBox System.Web.UI.WebControls.CompositeControl System.Web.UI.WebControls.DataListItem System.Web.UI.WebControls.FileUpload System.Web.UI.WebControls.HyperLink System.Web.UI Kvebcontrols Kimej Sistmkvebkuikvebcontrolsklebl Sistmkvebkuikvebcontrolsklinkbutton Sistmkvebkuikvebcontrolskloginname Sistmkvebkuikvebcontrolskpanl Sistmkvebkuikvebcontrolsksitmpanoditem system .Web .UI.WebControls.Table System.Web.UI.WebControls.TableCell system. WebkUIkWebControlskTableRow system. WebkUIkWebControlskTextBox system. Web.UI.WebControls.ValidationSummary
Comments
Post a Comment