public TextBox(TextBoxProps textBoxProps) : base(textBoxProps) { Lines.Add(""); p_Font = ContentLoader.GetFontByName("BitStreamRoman"); p_mode = TextBoxMode.Multiline; p_WordWrap = true; }
public static TextBox GetTextBox(string id, TextBoxMode textMode, int width, int rowCount, string css) { TextBox tb = new TextBox(); tb.ID = id; tb.TextMode = textMode; tb.Width = width; tb.Rows = rowCount; tb.CssClass = css; return tb; }
public ValidatorParams() { Enabled = false; RequireValidatorEnabled = false; MinValue = 0.ToString(); MaxValue = 0.ToString(); ContentType = ValidationDataType.String; ErrorMessage = "No error"; TextBoxTextMode = TextBoxMode.SingleLine; }
public ValidatorParams(bool enabled, double minValue, double maxValue, ValidationDataType contenType, string errorMessage, TextBoxMode textBoxTextMode, bool enableRequireValidator) { Enabled = enabled; MinValue = minValue.ToString(); MaxValue = maxValue.ToString(); ContentType = contenType; ErrorMessage = errorMessage; TextBoxTextMode = textBoxTextMode; RequireValidatorEnabled = enableRequireValidator; }
public DynamicCountableTextBoxXml(string text, string name, bool isRequired, string errorMessage, string validationGroup, int maxChars, int maxCharsWarning, TextBoxMode textMode, double width, double height, DynamicLabel label, string css, string style, bool visible) { _text = text; Name = name; _isRequired = isRequired; _errorMessage = errorMessage; _validationGroup = validationGroup; _MaxChars = maxChars; _MaxCharsWarning = maxCharsWarning; _textMode = textMode; _width = width; _height = height; Label = label; Css = css; Style = style; Visible = visible; }
internal static string GetTypeAttributeValue(TextBoxMode mode) { switch (mode) { case TextBoxMode.SingleLine: return("text"); case TextBoxMode.Password: return("password"); case TextBoxMode.Color: return("color"); case TextBoxMode.Date: return("date"); case TextBoxMode.DateTime: return("datetime"); case TextBoxMode.DateTimeLocal: return("datetime-local"); case TextBoxMode.Email: return("email"); case TextBoxMode.Month: return("month"); case TextBoxMode.Number: return("number"); case TextBoxMode.Range: return("range"); case TextBoxMode.Search: return("search"); case TextBoxMode.Phone: return("tel"); case TextBoxMode.Time: return("time"); case TextBoxMode.Url: return("url"); case TextBoxMode.Week: return("week"); case TextBoxMode.MultiLine: // falling through on purpose default: // the default case could only happen if // - someone forces an out-of-range value as a TextBoxMode and passes it in // - a new TextBoxMode value gets added, in which case it should be handled as an explicit case above throw new InvalidOperationException(); } }
/// <summary> /// Builds the textbox. /// </summary> public static IHtmlString BuildTextBox <TBuilder>(TBuilder instance) where TBuilder : ITextBoxBuilder, IHtmlHelper { TextBoxMode mode = instance.Mode(); switch (mode) { case TextBoxMode.Password: return(instance.Html.Password(instance.Name(), instance.Val(), instance.HtmlAttributes)); case TextBoxMode.MultiLine: return(instance.Html.TextArea(instance.Name(), Convert.ToString(instance.Val()), instance.Attr <int>("rows"), instance.Attr <int>("cols"), instance.HtmlAttributes)); } return(instance.Html.TextBox(instance.Name(), instance.Val(), instance.Format(), instance.HtmlAttributes)); }
/// <summary> /// Builds the text box. /// </summary> public static IHtmlString BuildTextBoxFor <TModel, TProperty>(TextBoxBuilder <TModel, TProperty> instance) { if (instance.InitExpression == null) { return(BuildTextBox(instance)); } TextBoxMode mode = instance.Mode(); switch (mode) { case TextBoxMode.Password: return(instance.Html.PasswordFor(instance.InitExpression, instance.HtmlAttributes)); case TextBoxMode.MultiLine: return(instance.Html.TextAreaFor(instance.InitExpression, instance.Attr <int>("rows"), instance.Attr <int>("cols"), instance.HtmlAttributes)); default: return(instance.Html.TextBoxFor(instance.InitExpression, instance.Format(), instance.HtmlAttributes)); } }
protected internal override void SetParameters(System.Collections.IDictionary parms) { base.SetParameters(parms); if (parms.Contains("textmode")) { switch (((string)parms["textmode"]).ToLower()) { case "password": TextMode = TextBoxMode.Password; break; case "multiline": TextMode = TextBoxMode.MultiLine; break; default: TextMode = TextBoxMode.SingleLine; break; } } }
private void AddField(string dataField, string dataMember, bool required, string regexValidator, TextBoxMode textMode) { if (userForm.Items.Any(i => i.ID == dataField)) { return; } var formItem = new DnnFormTextBoxItem { ID = dataField, DataField = dataField, DataMember = dataMember, Visible = true, Required = required, TextMode = textMode }; if (!String.IsNullOrEmpty(regexValidator)) { formItem.ValidationExpression = regexValidator; } userForm.Items.Add(formItem); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { Page page = this.Page; if (page != null) { page.VerifyRenderingInServerForm(this); } string uniqueID = this.UniqueID; if (uniqueID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Name, uniqueID); } TextBoxMode textMode = this.TextMode; switch (textMode) { case TextBoxMode.MultiLine: { int rows = this.Rows; int columns = this.Columns; bool flag = false; if (!base.EnableLegacyRendering) { if (rows == 0) { rows = 2; } if (columns == 0) { columns = 20; } } if ((rows > 0) || flag) { writer.AddAttribute(HtmlTextWriterAttribute.Rows, rows.ToString(NumberFormatInfo.InvariantInfo)); } if ((columns > 0) || flag) { writer.AddAttribute(HtmlTextWriterAttribute.Cols, columns.ToString(NumberFormatInfo.InvariantInfo)); } if (!this.Wrap) { writer.AddAttribute(HtmlTextWriterAttribute.Wrap, "off"); } goto Label_0265; } case TextBoxMode.SingleLine: { if (string.IsNullOrEmpty(base.Attributes["type"])) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "text"); } if (((this.AutoCompleteType != System.Web.UI.WebControls.AutoCompleteType.None) && (this.Context != null)) && (this.Context.Request.Browser["supportsVCard"] == "true")) { if (this.AutoCompleteType == System.Web.UI.WebControls.AutoCompleteType.Disabled) { writer.AddAttribute(HtmlTextWriterAttribute.AutoComplete, "off"); } else if (this.AutoCompleteType == System.Web.UI.WebControls.AutoCompleteType.Search) { writer.AddAttribute(HtmlTextWriterAttribute.VCardName, "search"); } else if (this.AutoCompleteType == System.Web.UI.WebControls.AutoCompleteType.HomeCountryRegion) { writer.AddAttribute(HtmlTextWriterAttribute.VCardName, "HomeCountry"); } else if (this.AutoCompleteType == System.Web.UI.WebControls.AutoCompleteType.BusinessCountryRegion) { writer.AddAttribute(HtmlTextWriterAttribute.VCardName, "BusinessCountry"); } else { string str2 = Enum.Format(typeof(System.Web.UI.WebControls.AutoCompleteType), this.AutoCompleteType, "G"); if (str2.StartsWith("Business", StringComparison.Ordinal)) { str2 = str2.Insert(8, "."); } else if (str2.StartsWith("Home", StringComparison.Ordinal)) { str2 = str2.Insert(4, "."); } writer.AddAttribute(HtmlTextWriterAttribute.VCardName, "vCard." + str2); } } string text = this.Text; if (text.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Value, text); } break; } case TextBoxMode.Password: writer.AddAttribute(HtmlTextWriterAttribute.Type, "password"); break; } int maxLength = this.MaxLength; if (maxLength > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, maxLength.ToString(NumberFormatInfo.InvariantInfo)); } maxLength = this.Columns; if (maxLength > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Size, maxLength.ToString(NumberFormatInfo.InvariantInfo)); } Label_0265: if (this.ReadOnly) { writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly"); } if ((this.AutoPostBack && (page != null)) && page.ClientSupportsJavaScript) { string str4 = null; if (base.HasAttributes) { str4 = base.Attributes["onchange"]; if (str4 != null) { str4 = Util.EnsureEndWithSemiColon(str4); base.Attributes.Remove("onchange"); } } PostBackOptions options = new PostBackOptions(this, string.Empty); if (this.CausesValidation) { options.PerformValidation = true; options.ValidationGroup = this.ValidationGroup; } if (page.Form != null) { options.AutoPostBack = true; } str4 = Util.MergeScript(str4, page.ClientScript.GetPostBackEventReference(options, true)); writer.AddAttribute(HtmlTextWriterAttribute.Onchange, str4); if (textMode != TextBoxMode.MultiLine) { string str5 = "if (WebForm_TextBoxKeyHandler(event) == false) return false;"; if (base.HasAttributes) { string str6 = base.Attributes["onkeypress"]; if (str6 != null) { str5 = str5 + str6; base.Attributes.Remove("onkeypress"); } } writer.AddAttribute("onkeypress", str5); } if (base.EnableLegacyRendering) { writer.AddAttribute("language", "javascript", false); } } else if (page != null) { page.ClientScript.RegisterForEventValidation(this.UniqueID, string.Empty); } if ((this.Enabled && !base.IsEnabled) && this.SupportsDisabledAttribute) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } base.AddAttributesToRender(writer); }
internal static string GetTypeAttributeValue(TextBoxMode mode) { switch (mode) { case TextBoxMode.SingleLine: return "text"; case TextBoxMode.Password: return "password"; case TextBoxMode.Color: return "color"; case TextBoxMode.Date: return "date"; case TextBoxMode.DateTime: return "datetime"; case TextBoxMode.DateTimeLocal: return "datetime-local"; case TextBoxMode.Email: return "email"; case TextBoxMode.Month: return "month"; case TextBoxMode.Number: return "number"; case TextBoxMode.Range: return "range"; case TextBoxMode.Search: return "search"; case TextBoxMode.Phone: return "tel"; case TextBoxMode.Time: return "time"; case TextBoxMode.Url: return "url"; case TextBoxMode.Week: return "week"; case TextBoxMode.MultiLine: // falling through on purpose default: // the default case could only happen if // - someone forces an out-of-range value as a TextBoxMode and passes it in // - a new TextBoxMode value gets added, in which case it should be handled as an explicit case above throw new InvalidOperationException(); } }
private void AddField(string dataField, string dataMember, bool required, string regexValidator, TextBoxMode textMode) { var formItem = new DnnFormTextBoxItem { ID = dataField, DataField = dataField, DataMember = dataMember, Visible = true, Required = required, TextMode = textMode }; if (!String.IsNullOrEmpty(regexValidator)) { formItem.ValidationExpression = regexValidator; } userForm.Items.Add(formItem); }
public static TextBox CreateTextBox(string id, int maxLen, string keyjs, string valuejs, string value, bool isReadOnly, TextBoxMode textmode, string css) { List <KeyValuePair <string, string> > keyValuePairs = new List <KeyValuePair <string, string> >(); if (keyjs != string.Empty) { keyValuePairs.Add(new KeyValuePair <string, string>(keyjs, valuejs)); } TextBox textBox = WebUtils.CreateTextBox(id, maxLen, keyValuePairs, value, isReadOnly, textmode, css); return(textBox); }
protected void Page_Load(object sender, EventArgs e) { ///사용자 로그인여부를 확인합니다. chkUserId(); if (!IsPostBack) { ///직위list를 만들어준다. string jwcdsql = @"select comcd, comcdnm from pjt_comcd where upcd = '10' order by comcd"; DataTable jwcddt = GetDataTable(jwcdsql); if (jwcddt.Rows.Count > 0) { makeSelectList(cboUserPosition, jwcddt, "comcdnm", "comcd"); } jwcddt.Clear(); jwcddt.Dispose(); ///선택된 사용자가 있는 경우 해당 사용자를 조회해서 data를 display if (!string.IsNullOrEmpty(Request.QueryString["devempid"]) && Request.QueryString["devempid"].ToString() != "") { string connectionString = ConfigurationManager.ConnectionStrings["DBConnect"].ConnectionString; string empsql = @"select devempid, devempnm, devemppw, jwcd, email, oftel, hptel, emplvl from pjt_devemp where devempid = '" + Request.QueryString["devempid"].ToString() + "'"; // Connect to the database and run the query. SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.Text; cmd.CommandText = empsql; cmd.Parameters.Add("@devempid", SqlDbType.VarChar, 10).Value = Request.QueryString["devempid"].ToString(); SqlDataReader reader = cmd.ExecuteReader(); TextBoxMode passMode = txtUserPassword.TextMode; TextBoxMode textMode = txtUserID.TextMode; if (reader.Read()) { txtUserID.Text = reader["devempid"].ToString(); hdnUserID.Value = reader["devempid"].ToString(); txtUserName.Text = reader["devempnm"].ToString(); txtUserPassword.TextMode = textMode; txtUserPasswordConfirm.TextMode = textMode; txtUserPassword.Text = reader["devemppw"].ToString(); txtUserPasswordConfirm.Text = reader["devemppw"].ToString(); txtUserPassword.TextMode = passMode; txtUserPasswordConfirm.TextMode = passMode; txtUserEmail.Text = reader["email"].ToString(); txtUserTel.Text = reader["oftel"].ToString(); txtUserMobile.Text = reader["hptel"].ToString(); if (reader["emplvl"].ToString() == "1") { chkIsAdmin.Checked = true; } cboUserPosition.SelectedValue = reader["jwcd"].ToString(); btnSave.Text = "수정"; btnDelete.Visible = true; } cmd.Dispose(); reader.Dispose(); reader.Close(); conn.Dispose(); conn.Close(); } else { btnDelete.Visible = false; } //DB에서 개발자 정보를 가져와서 listDeveloper에 입력한다. listQuery(); //관리자가 아니였을때의 처리 if (Request.Cookies["UserSettings"] != null && Request.Cookies["UserSettings"]["USERLVL"] != "1") { //listDeveloper.Visible = false; // 개발자목록 비노출 listPanel.Visible = false; // 개발자목록 비노출 txtUserID.ReadOnly = true; // UserID ReadOnly lblIsAdmin.Visible = false; // 관리자체크항목 비노출 chkIsAdmin.Visible = false; // 관리자체크항목 비노출 btnDelete.Visible = false; // 삭제버튼 비노출 btnReset.Visible = false; //초기화버튼 비노출 } } }
public static TextBox CreateTextBox(string id, int maxLen, List <KeyValuePair <string, string> > js, string value, bool isReadOnly, TextBoxMode textmode, string css) { TextBox textBox = new TextBox() { ID = id, MaxLength = maxLen, Columns = maxLen, TextMode = textmode, CssClass = css }; foreach (KeyValuePair <string, string> j in js) { string key = j.Key; string str = j.Value; if (key != string.Empty) { textBox.Attributes.Add(key, str); } } textBox.Text = value; textBox.ReadOnly = isReadOnly; return(textBox); }
public TextBoxBuilder Mode(TextBoxMode value) { base.Options["mode"] = value; return(this); }
private void AddFieldToForm(ref DnnFormEditor RegistrationForm, string dataField, string dataMember, bool required, string regexValidator, TextBoxMode textMode) { var formItem = new DnnFormTextBoxItem { ID = dataField, DataField = dataField, DataMember = dataMember, Visible = true, Required = required, TextMode = textMode }; if (!String.IsNullOrEmpty(regexValidator)) { formItem.ValidationExpression = regexValidator; } RegistrationForm.Items.Add(formItem); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { using (var w = new HtmlTextWriterWithAttributeFilter(writer)) { Page.VerifyRenderingInServerForm(this); w.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); TextBoxMode mode = this.TextMode; if (mode == TextBoxMode.MultiLine) { int rows = this.Rows; if (rows > 0) { w.AddAttribute(HtmlTextWriterAttribute.Rows, rows.ToString(NumberFormatInfo.InvariantInfo)); } int cols = this.Columns; if (cols > 0) { w.AddAttribute(HtmlTextWriterAttribute.Cols, cols.ToString(NumberFormatInfo.InvariantInfo)); } } else { if (mode == TextBoxMode.SingleLine) { w.AddAttribute(HtmlTextWriterAttribute.Type, "text"); string value = this.Text; if (value.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Value, value); } } else if (mode == TextBoxMode.Password) { w.AddAttribute(HtmlTextWriterAttribute.Type, "password"); } int ml = this.MaxLength; if (ml > 0) { w.AddAttribute(HtmlTextWriterAttribute.Maxlength, ml.ToString(NumberFormatInfo.InvariantInfo)); } int size = this.Columns; if (size > 0) { w.AddAttribute(HtmlTextWriterAttribute.Size, size.ToString(NumberFormatInfo.InvariantInfo)); } } if (this.ReadOnly) { w.AddAttribute(HtmlTextWriterAttribute.ReadOnly, ((OSPage)Page).QuirksMode ? null : "readonly"); } // [#35738] add to class='' the Mandatory style if (this._mandatory) { string cssClass = this.CssClass; if (cssClass != null && cssClass != "") { this.CssClass = this.CssClass + " Mandatory"; } else { this.CssClass = "Mandatory"; } } // [#35738] add to class='' the Valid style if (!this._valid) { string cssClass = this.CssClass; if (cssClass != null && cssClass != "") { this.CssClass = this.CssClass + " Not_Valid"; } else { this.CssClass = "Not_Valid"; } } // dump ajax onchange handler AjaxEventsHelper.AddAjaxEventAttribute(this, AjaxEventType.onAjaxChange, ClientID, UniqueID, "__OSVSTATE", ViewStateAttributes.InlineAttributes); base.AddAttributesToRender(w); ViewStateAttributes.InlineAttributes.AddAttributes(w); } }
public override void SetValue(string value) { if (ViewMode == FormControlViewMode.Development) { Dictionary<string, string> options = GetOptionsFromXml(value); if (!string.IsNullOrEmpty(options["DefaultValue"])) DefaultValue = options["DefaultValue"]; if (!string.IsNullOrEmpty(options["CssClass"])) CssClass = options["CssClass"]; if (!string.IsNullOrEmpty(options["TextBoxMode"])) TextMode = (TextBoxMode)Enum.Parse(typeof(TextBoxMode), options["TextBoxMode"]); if (!string.IsNullOrEmpty(options["Rows"])) Rows = options["Rows"]; if (!string.IsNullOrEmpty(options["Cols"])) Cols = options["Cols"]; } else { if (!string.IsNullOrEmpty(value)) DefaultValue = value; } }
/// <internalonly/> /// <devdoc> /// </devdoc> protected override void AddAttributesToRender(HtmlTextWriter writer) { // Make sure we are in a form tag with runat=server. Page page = Page; if (page != null) { page.VerifyRenderingInServerForm(this); } string uniqueID = UniqueID; if (uniqueID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Name, uniqueID); } TextBoxMode mode = TextMode; if (mode == TextBoxMode.MultiLine) { // MultiLine renders as textarea int rows = Rows; int columns = Columns; bool adapterRenderZeroRowCol = false; if (!EnableLegacyRendering) { // VSWhidbey 497755 if (rows == 0) { rows = DefaultMutliLineRows; } if (columns == 0) { columns = DefaultMutliLineColumns; } } if (rows > 0 || adapterRenderZeroRowCol) { writer.AddAttribute(HtmlTextWriterAttribute.Rows, rows.ToString(NumberFormatInfo.InvariantInfo)); } if (columns > 0 || adapterRenderZeroRowCol) { writer.AddAttribute(HtmlTextWriterAttribute.Cols, columns.ToString(NumberFormatInfo.InvariantInfo)); } if (!Wrap) { writer.AddAttribute(HtmlTextWriterAttribute.Wrap, "off"); } } else { // Everything else renders as input if (mode != TextBoxMode.SingleLine || String.IsNullOrEmpty(Attributes["type"])) { // If the developer specified a custom type (like an HTML 5 type), use that type instead of "text". // The call to base.AddAttributesToRender at the end of this method will add the custom type if specified. writer.AddAttribute(HtmlTextWriterAttribute.Type, GetTypeAttributeValue(mode)); } AutoCompleteType autoCompleteType = AutoCompleteType; if (mode == TextBoxMode.SingleLine && autoCompleteType != AutoCompleteType.None && autoCompleteType != AutoCompleteType.Enabled && autoCompleteType != AutoCompleteType.Disabled && SupportsVCard) { // Renders the vcard_name attribute so that client browsers can support autocomplete string name = GetVCardAttributeValue(autoCompleteType); writer.AddAttribute(HtmlTextWriterAttribute.VCardName, name); } if (autoCompleteType == AutoCompleteType.Disabled && (RenderingCompatibility >= VersionUtil.Framework45 || mode >= TextBoxMode.Color || (SupportsVCard && mode == TextBoxMode.SingleLine))) { // Only render autocomplete="off" when one of the following is true // - 4.5 or higher rendering compat is being used // - any of the new HTML5 modes are being used // - browser supports vCard AND mode is SingleLine (this is the legacy pre-4.5 behavior) writer.AddAttribute(HtmlTextWriterAttribute.AutoComplete, "off"); } if (autoCompleteType == AutoCompleteType.Enabled) { // Since Enabled is a new value in .NET 4.5 we don't need back-compat switches writer.AddAttribute(HtmlTextWriterAttribute.AutoComplete, "on"); } if (mode != TextBoxMode.Password) { // only render value if we're not a password string s = Text; if (s.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Value, s); } } int n = MaxLength; if (n > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, n.ToString(NumberFormatInfo.InvariantInfo)); } n = Columns; if (n > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Size, n.ToString(NumberFormatInfo.InvariantInfo)); } } if (ReadOnly) { writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly"); } if (AutoPostBack && (page != null) && page.ClientSupportsJavaScript) { string onChange = null; if (HasAttributes) { onChange = Attributes["onchange"]; if (onChange != null) { onChange = Util.EnsureEndWithSemiColon(onChange); Attributes.Remove("onchange"); } } PostBackOptions options = new PostBackOptions(this, String.Empty); // ASURT 98368 // Need to merge the autopostback script with the user script if (CausesValidation) { options.PerformValidation = true; options.ValidationGroup = ValidationGroup; } if (page.Form != null) { options.AutoPostBack = true; } onChange = Util.MergeScript(onChange, page.ClientScript.GetPostBackEventReference(options, true)); writer.AddAttribute(HtmlTextWriterAttribute.Onchange, onChange); // VSWhidbey 482068: Enter key should be preserved in mult-line // textbox so the textBoxKeyHandlerCall should not be hooked up if (mode != TextBoxMode.MultiLine) { string onKeyPress = _textBoxKeyHandlerCall; if (HasAttributes) { string userOnKeyPress = Attributes["onkeypress"]; if (userOnKeyPress != null) { onKeyPress += userOnKeyPress; Attributes.Remove("onkeypress"); } } writer.AddAttribute("onkeypress", onKeyPress); } if (EnableLegacyRendering) { writer.AddAttribute("language", "javascript", false); } } else if (page != null) { page.ClientScript.RegisterForEventValidation(this.UniqueID, String.Empty); } if (Enabled && !IsEnabled && SupportsDisabledAttribute) { // We need to do the cascade effect on the server, because the browser // only renders as disabled, but doesn't disable the functionality. writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } base.AddAttributesToRender(writer); }
// Returns a Label and Panel within a Tuple. We used a Tuple because Labels and Panels are always paired public static Tuple <Label, Panel> BuildLabelTextBoxPair(string labelId, string labelText, string textBoxId, string textBoxContent = null, TextBoxMode txtBoxMode = TextBoxMode.SingleLine, int colSpan = 25, int rowSpan = 1) { var label = new Label(); label.Text = labelText; label.CssClass = "col-sm-3 control-label"; label.ID = labelId; Panel panel = new Panel(); panel.CssClass = "col-sm-9"; var textBox = new TextBox(); textBox.ID = textBoxId; textBox.TextMode = txtBoxMode; textBox.Columns = colSpan; textBox.Rows = rowSpan; textBox.Text = textBoxContent; textBox.CssClass = "form-control"; panel.Controls.Add(textBox); return(new Tuple <Label, Panel>(label, panel)); }
public override void SetOptions(string xmloptions) { if (!string.IsNullOrEmpty(xmloptions)) { Dictionary<string, string> options = GetOptionsFromXml(xmloptions); if (!string.IsNullOrEmpty(options["DefaultValue"])) DefaultValue = options["DefaultValue"]; if (!string.IsNullOrEmpty(options["CssClass"])) CssClass = options["CssClass"]; if (!string.IsNullOrEmpty(options["TextBoxMode"])) TextMode = (TextBoxMode)Enum.Parse(typeof(TextBoxMode), options["TextBoxMode"]); if (!string.IsNullOrEmpty(options["Rows"])) Rows = options["Rows"]; if (!string.IsNullOrEmpty(options["Cols"])) Cols = options["Cols"]; } }
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.AddAttributesToRender"]/*' /> /// <internalonly/> /// <devdoc> /// </devdoc> protected override void AddAttributesToRender(HtmlTextWriter writer) { // Make sure we are in a form tag with runat=server. if (Page != null) { Page.VerifyRenderingInServerForm(this); } writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); TextBoxMode mode = TextMode; int n; if (mode == TextBoxMode.MultiLine) { // MultiLine renders as textarea n = Rows; if (n > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Rows, n.ToString(NumberFormatInfo.InvariantInfo)); } n = Columns; if (n > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Cols, n.ToString(NumberFormatInfo.InvariantInfo)); } if (!Wrap) { writer.AddAttribute(HtmlTextWriterAttribute.Wrap, "off"); } } else { // SingleLine renders as input if (mode == TextBoxMode.SingleLine) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "text"); // only render value if we're not a password string s = Text; if (s.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Value, s); } } else if (mode == TextBoxMode.Password) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "password"); } n = MaxLength; if (n > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, n.ToString(NumberFormatInfo.InvariantInfo)); } n = Columns; if (n > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Size, n.ToString(NumberFormatInfo.InvariantInfo)); } } if (ReadOnly) { writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly"); } if (AutoPostBack && Page != null) { // ASURT 98368 // Need to merge the autopostback script with the user script string onChange = Page.GetPostBackClientEvent(this, ""); if (HasAttributes) { string userOnChange = Attributes["onchange"]; if (userOnChange != null) { onChange = userOnChange + onChange; Attributes.Remove("onchange"); } } writer.AddAttribute(HtmlTextWriterAttribute.Onchange, onChange); writer.AddAttribute("language", "javascript"); } base.AddAttributesToRender(writer); }