Get the ConnectionString from the Web.Config file with only one line of code (C#):
var conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"]; string strConnString = conString.ConnectionString;
var conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"]; string strConnString = conString.ConnectionString;
public static Control[] FlattenHierachy(Control root) { List<Control> list = new List<Control>(); list.Add(root); if (root.HasControls()) { foreach (Control control in root.Controls) { list.AddRange(FlattenHierachy(control)); } } return list.ToArray(); }As you can see, it is pretty simple. The method recursively traverses control hierarchy and collects each control it finds on its way to a collection which is finally returned to the caller in a form of an array.
private void MakeTextBoxesReadOnly() { Control[] allControls = FlattenHierachy(Page); foreach (Control control in allControls) { TextBox textBox = control as TextBox; if (textBox != null) { textBox.ReadOnly = true; } } }Using a combination of the above outlined methods it is easy to implement a kind of ReadOnlyMode page filter. Just identify what controls need to be ReadOnly and how to make them so (RadioButton for example doesn't have a ReadOnly property). When you know how and what you want to make ReadOnly, just override Page's OnPreRender method by adding a call a MakeTextBoxesReadOnly method (or whatever method you create).
<asp:Button ID="Button2"
runat="server"
Text="Delete" onclick="Button2_Click"
onclientclick="return confirm('Are you sure you want to Delete this Apointment ?');" />
Simple?