private void SetCurrentObjectProperty(string PropertyName) { System.Reflection.PropertyInfo pi = CurrentObject.GetType().GetProperty(PropertyName); if (pi.CanWrite == true) { try { object val = ((FieldEditControl)EditTable.FindControl("edit" + PropertyName)).EditValue; if (pi.PropertyType.IsEnum) { pi.SetValue(CurrentObject, System.Enum.Parse(pi.PropertyType, val.ToString()), null); } else { pi.SetValue(CurrentObject, System.Convert.ChangeType(val, pi.PropertyType), null); } } catch (System.Exception exc) { ShowException(exc); } } }
/// <summary> /// Enables and disables the checkboxes in the tables for the databases if they support the languages. /// </summary> /// <param name="tbl">Table web control</param> /// <param name="lang">Language</param> /// <param name="db">Database</param> private void CheckIfDatabaseHasLanguage(System.Web.UI.WebControls.Table tbl, LanguageSettings lang, DatabaseInfo db) { CheckBox chk = (CheckBox)tbl.FindControl(lang.Name + SEPARATOR + db.Id); if (!db.HasLanguage(lang.Name)) { chk.Enabled = false; } }
/// <summary> /// If the database is exposed via the API its checkbox in the table will be checked /// </summary> /// <param name="tbl">Table web control</param> /// <param name="lang">Language</param> /// <param name="db">Database</param> private void CheckIfExposedDatabase(System.Web.UI.WebControls.Table tbl, LanguageSettings lang, DatabaseInfo db) { if (PCAxis.Query.ExposedDatabases.DatabaseConfigurations[lang.Name].ContainsKey(db.Id)) { CheckBox chk = (CheckBox)tbl.FindControl(lang.Name + SEPARATOR + db.Id); if (chk != null) { chk.Checked = true; } } }
/// <summary> /// The Page_Load event on this Page is used to ... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Load(object sender, System.EventArgs e) { if (!(Request.Params["UserDefinedRowID"] == null)) { UserDefinedRowID = Int32.Parse(Request.Params["UserDefinedRowID"].ToString()); } BuildTable(); if (Page.IsPostBack == false) { if (UserDefinedRowID != -1) { Control tb; UserDefinedTableDB objUserDefinedTable = new UserDefinedTableDB(); SqlDataReader dr = objUserDefinedTable.GetSingleUserDefinedRow(UserDefinedRowID, ModuleID); try { while (dr.Read()) { tb = tblFields.FindControl(dr["FieldTitle"].ToString()); if (tb != null) { if (tb.GetType() == typeof(TextBox)) { ((TextBox)tb).Text = dr["FieldValue"].ToString(); } if (tb.GetType() == typeof(DropDownList)) { if (((DropDownList)tb).Items.Count > 0) { try{ ((DropDownList)tb).Items.FindByValue(dr["FieldValue"].ToString()).Selected = true; } catch { ((DropDownList)tb).Items[0].Selected = true; } } } } } } finally { dr.Close(); } } else { this.deleteButton.Visible = false; } } }
void Role_SelectedIndexChanged(Object sender, EventArgs e) { DropDownList ddlSelected = (DropDownList)sender; //if (ddlSelected.SelectedIndex > 0) //{ clsAuthorizationDetails objAthen = new clsAuthorizationDetails(); List <EntAuthorizationDetails> lst; lst = objAthen.GetAthenDetails(int.Parse(ddlSelected.SelectedValue)); for (int iloop = 0; iloop < lst.Count; iloop++) { if (lst[iloop].ModuleID == clsConstant.NOMIATION_ID) { List <EntNomAuthorizationDetails> lstNom; lstNom = objAthen.GetNomAthenDetails(lst[iloop].RoleID); if (lstNom.Count > 0) { ((CheckBox)tblModule.FindControl("chkView" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = lst[0].isView; ((CheckBox)tblModule.FindControl("chkUpload" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = lstNom[0].isUpload; ((CheckBox)tblModule.FindControl("chkShortList" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = lstNom[0].isShortList; ((CheckBox)tblModule.FindControl("chkApprove" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = lstNom[0].isApprove; } else { ((CheckBox)tblModule.FindControl("chkView" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkUpload" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkShortList" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkApprove" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = false; } } else { ((CheckBox)tblModule.FindControl("chkView" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = lst[iloop].isView; ((CheckBox)tblModule.FindControl("chkEdit" + ddlSelected.ID + "_" + lst[iloop].ModuleID)).Checked = lst[iloop].isEdit; } } if (lst.Count == 0) { List <EntModuleDetails> lstModule = (List <EntModuleDetails>)Session[clsConstant.SESS_MODULE]; for (int jloop = 0; jloop < lstModule.Count; jloop++) { if (lstModule[jloop].ModuleID == clsConstant.NOMIATION_ID) { ((CheckBox)tblModule.FindControl("chkView" + ddlSelected.ID + "_" + lstModule[jloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkUpload" + ddlSelected.ID + "_" + lstModule[jloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkShortList" + ddlSelected.ID + "_" + lstModule[jloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkApprove" + ddlSelected.ID + "_" + lstModule[jloop].ModuleID)).Checked = false; } else { ((CheckBox)tblModule.FindControl("chkView" + ddlSelected.ID + "_" + lstModule[jloop].ModuleID)).Checked = false; ((CheckBox)tblModule.FindControl("chkEdit" + ddlSelected.ID + "_" + lstModule[jloop].ModuleID)).Checked = false; } } } //} }
private string ConvertTableToHtmlTable(Table originalTable, System.Web.UI.Control container, IDictionary persistMap) { IList list = new ArrayList(); foreach (System.Web.UI.Control control in originalTable.Controls) { list.Add(control); } Table child = new Table(); foreach (System.Web.UI.Control control2 in list) { child.Controls.Add(control2); } if (originalTable.ControlStyleCreated) { child.ApplyStyle(originalTable.ControlStyle); } child.Width = ((WebControl) base.ViewControl).Width; child.Height = ((WebControl) base.ViewControl).Height; if (container != null) { container.Controls.Add(child); container.Controls.Remove(originalTable); } IDesignerHost service = (IDesignerHost) this.GetService(typeof(IDesignerHost)); if (persistMap != null) { foreach (string str in persistMap.Keys) { System.Web.UI.Control control3 = child.FindControl(str); if ((control3 != null) && control3.Visible) { control3.ID = (string) persistMap[str]; LiteralControl control4 = new LiteralControl(ControlPersister.PersistControl(control3, service)); control3.Parent.Controls.Add(control4); control3.Parent.Controls.Remove(control3); } } } foreach (string str3 in _persistedControlIDs) { System.Web.UI.Control control5 = child.FindControl(str3); if (control5 != null) { if (Array.IndexOf<string>(_persistedIfNotVisibleControlIDs, str3) >= 0) { control5.Visible = true; control5.Parent.Visible = true; control5.Parent.Parent.Visible = true; } if (str3 == "ErrorMessage") { TableCell parent = (TableCell) control5.Parent; parent.ForeColor = Color.Red; parent.ApplyStyle(this._createUserWizard.ErrorMessageStyle); control5.EnableViewState = false; } if (control5.Visible) { LiteralControl control6 = new LiteralControl(ControlPersister.PersistControl(control5, service)); control5.Parent.Controls.Add(control6); control5.Parent.Controls.Remove(control5); } } } StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter writer2 = new HtmlTextWriter(writer); child.RenderControl(writer2); return writer.ToString(); }
private void Page_Load(object sender, System.EventArgs e) { string _tmpString_ = "This is a <Test String>."; _tmpString_ = Server.HtmlEncode(_tmpString_); // -> "This is a <Test String>." _tmpString_ = Server.HtmlDecode(_tmpString_); // -> "This is a <Test String>." _tmpString_ = HttpUtility.HtmlEncode(_tmpString_); // -> "This is a <Test String>." _tmpString_ = HttpUtility.HtmlDecode(_tmpString_); // -> "This is a <Test String>." _tmpString_ = Server.UrlEncode(_tmpString_); // -> "This+is+a+%3cTest+String%3e." _tmpString_ = Server.UrlDecode(_tmpString_); // -> "This is a <Test String>." _tmpString_ = HttpUtility.UrlEncode(_tmpString_); // -> "This+is+a+%3cTest+String%3e." _tmpString_ = HttpUtility.UrlDecode(_tmpString_); // -> "This is a <Test String>." _tmpString_ = "Это - тест <\"ПрЫвЭт!!!\">"; _tmpString_ = Server.HtmlEncode(_tmpString_); _tmpString_ = Server.HtmlDecode(_tmpString_); _tmpString_ = HttpUtility.HtmlEncode(_tmpString_); _tmpString_ = HttpUtility.HtmlDecode(_tmpString_); _tmpString_ = Server.UrlEncode(_tmpString_); _tmpString_ = Server.UrlDecode(_tmpString_); _tmpString_ = HttpUtility.UrlEncode(_tmpString_); _tmpString_ = HttpUtility.UrlDecode(_tmpString_); _tmpString_ = "Привет"; _tmpString_ = Server.UrlEncode(_tmpString_); _tmpString_ = Server.UrlDecode(_tmpString_); _tmpString_ = HttpUtility.UrlEncode(_tmpString_); _tmpString_ = HttpUtility.UrlDecode(_tmpString_); _tmpString_ = "При\nвет\r\n"; _tmpString_ = Server.UrlEncode(_tmpString_); _tmpString_ = Server.UrlDecode(_tmpString_); _tmpString_ = HttpUtility.UrlEncode(_tmpString_); _tmpString_ = HttpUtility.UrlDecode(_tmpString_); _tmpString_ = Request.Url.Scheme; _tmpString_ += Uri.SchemeDelimiter; _tmpString_ += Request.Url.Host; _tmpString_ += Request.Url.IsDefaultPort ? string.Empty : ":" + Request.Url.Port; _tmpString_ += ResolveUrl("~/MainTitle.aspx"); LabelPage.Text += "PageLoad: " + DateTime.Now.ToString("hh:mm:ss") + " (IsPostBack=\"" + IsPostBack.ToString() + "\")<br>"; if (!IsPostBack) { LabelEnvironmentCurrentDirectory.Text += Environment.CurrentDirectory; IEnumerator keys = TestDiv.Style.Keys.GetEnumerator(); String key; while (keys.MoveNext()) { key = (String)keys.Current; DivLabelInfo.Text += "[" + key + "]=" + TestDiv.Style[key] + "<br>"; } TextBox1.ToolTip = "Line 1\nLine 2"; LabelApplication.Text = String.Format("User Online={0}", (int)(Application["UserOnline"])); MainTable.Border = 3; TableRow row; TableCell cell; int i; for (i = 0; i < 2; ++i) { row = new TableRow(); for (int j = 0; j < 2; ++j) { cell = new TableCell(); cell.Text = String.Format("Row {0}, Column {1}", i + 1, j + 1); row.Cells.Add(cell); } Table2.Rows.Add(row); } DateTime date; for (i = 0; i < 5; ++i) { date = DateTime.Today + new TimeSpan(i, 0, 0, 0); DropDownListDate.Items.Add(date.ToString("MMMM dd, yyyy")); } DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("data/rates.xml")); ListBox2.DataSource = ds; ListBox2.DataTextField = "Currency"; ListBox2.DataValueField = "Exchange"; ListBox2.DataBind(); ListBox2.SelectedIndex = 3; Cell11.BorderColor = "red"; Cell11.BgColor = "green"; for (i = 100; i <= 1000; i += 100) { TableDropDownList.Items.Add(i.ToString()); } ArrayList a = new ArrayList(); for (i = 50; i <= 1000; i += 50) { a.Add(i.ToString()); } TableListBox.DataSource = a; TableListBox.DataBind(); string[] beatles = { "John", "Paul", "George", "Ringo" }; ListBoxAdd1.DataSource = beatles; ListBoxAdd1.DataBind(); ListBoxAdd2.DataSource = new Beatles(); ListBoxAdd2.DataBind(); DropDownListTestDataBind.DataSource = new BeatlesII(); DropDownListTestDataBind.DataTextField = "Name"; DropDownListTestDataBind.DataValueField = "Id"; DropDownListTestDataBind.DataBind(); DropDownListTestDataBindII.DataSource = new BeatlesII(); DropDownListTestDataBindII.DataValueField = "Name"; DropDownListTestDataBindII.DataTextField = "Id"; DropDownListTestDataBindII.DataBind(); ImageButton4.Attributes["onclick"] = "return(confirm('Submit?'));"; ImageButton5.Attributes["onclick"] = "return(false);"; ListBox1.Attributes.Add("ondblclick", "alert('ondblclick');"); DropDownListDate.Attributes.Add("ondblclick", "alert('ondblclick');"); Button3.Attributes.Add("onclick", "alert('ковычки \u0022');"); DataTable SmthTable = new DataTable(); string SmthFieldName = "Id"; SmthTable.Columns.Add(SmthFieldName, typeof(int)); DataRow tmpDataRow = SmthTable.NewRow(); tmpDataRow[SmthFieldName] = 1; SmthTable.Rows.Add(tmpDataRow); tmpDataRow = SmthTable.NewRow(); tmpDataRow[SmthFieldName] = 2; SmthTable.Rows.Add(tmpDataRow); tmpDataRow = SmthTable.NewRow(); tmpDataRow[SmthFieldName] = 3; SmthTable.Rows.Add(tmpDataRow); string tmpString = String.Empty; foreach (DataRow _row_ in SmthTable.Rows) { if (tmpString != String.Empty) { tmpString += ","; } tmpString += !_row_.IsNull(SmthFieldName) ? "\"" + Convert.ToString(_row_[SmthFieldName]).Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"" : "null"; } VarDef.Text = "\n<script type=\"text/javascript\">\n<!--\n"; VarDef.Text += "ArrayName=[" + tmpString + "];"; VarDef.Text += "\n// -->\n</script>"; Button4.Attributes.Add("onclick", "return(confirm('ahha?\\r\\nahha?'));"); } else { LabelTextBoxReadOnly.Text = TextBoxReadOnly.Text; string tmpString = TextBox3.Text; if ((tmpString.IndexOf("\r\n")) != -1) { tmpString = tmpString.Replace("\r\n", " ").Trim(); } TextBox3.Text = tmpString; lock (typeof(TestClassWithStatic)) { LabelStaticValue.Text = Convert.ToString(TestClassWithStatic.Counter) + "->" + Convert.ToString(--TestClassWithStatic.Counter) + " (SessionID: " + Session.SessionID + ")"; } TextBox TextBoxInput, TextBoxOutput; if ((TextBoxInput = NewDynamicTable.FindControl("TextBoxInput__0") as TextBox) != null && (TextBoxOutput = NewDynamicTable.FindControl("TextBoxOutput__0") as TextBox) != null) { TextBoxOutput.Text = TextBoxInput.Text; } else if ((TextBoxInput = NewDynamicTable.Rows[0].FindControl("TextBoxInput__0") as TextBox) != null && (TextBoxOutput = NewDynamicTable.Rows[0].FindControl("TextBoxOutput__0") as TextBox) != null) { TextBoxOutput.Text = TextBoxInput.Text; } else if ((TextBoxInput = NewDynamicTable.Rows[0].Cells[0].FindControl("TextBoxInput__0") as TextBox) != null && (TextBoxOutput = NewDynamicTable.Rows[0].Cells[0].FindControl("TextBoxOutput__0") as TextBox) != null) { TextBoxOutput.Text = TextBoxInput.Text; } for (int row = 0; row < NewDynamicTable.Rows.Count; ++row) { for (int col = 0; col < NewDynamicTable.Rows[row].Cells.Count; ++col) { if ((TextBoxInput = NewDynamicTable.Rows[row].Cells[col].FindControl("TextBoxInput__" + row) as TextBox) != null && (TextBoxOutput = NewDynamicTable.Rows[row].Cells[col].FindControl("TextBoxOutput__" + row) as TextBox) != null) { TextBoxOutput.Text = TextBoxInput.Text; } } } #region DropDownListEnabledDisabled DropDownListEnabledDisabled.Enabled = Request.Form.GetValues("DropDownListEnabledDisabled") != null; string[] ParamArray = Request.Form.GetValues("DropDownListEnabledDisabled"); string ParamValue = string.Empty; if (ParamArray != null && ParamArray.Length > 0) { ParamValue = ParamArray[0]; } LabelDropDownListEnabledDisabled.Text = ParamValue; #endregion #region Test __doPostBack() tmpString = Request.Form["__EVENTTARGET"]; tmpString = Request.Form["__EVENTARGUMENT"]; #endregion } #region System.Web.UI.WebControls.Literal if (LiteralWOVS.EnableViewState) { LiteralWOVS.EnableViewState = false; } if (!IsPostBack) { LiteralWVS.Text = "<!-- LiteralWVS -->"; LiteralWOVS.Text = "<!-- LiteralWOVS -->"; } else { _tmpString_ = "\"" + LiteralWVS.Text + "\""; if (_tmpString_ != string.Empty) { _tmpString_ += Environment.NewLine; } _tmpString_ = "\"" + LiteralWOVS.Text + "\""; } #endregion }