protected void SetTextbox(ASPxTextBox tbx, String validate = null) { tbx.Width = 170; if (!String.IsNullOrEmpty(validate)) { tbx.SetValidation(validate); } }
private void InitializeControls() { ab = new List <ASPxTextBox>(); pw = new List <DevExpress.Web.ASPxPopupControl.PopupWindow>(); pppHint.ClientInstanceName = this.ClientID + pppHint.ID; //IList<Language> listLanguage = Language.List(iSabayaContext); String idName = "", idPopupName = ""; foreach (Language l in Language.Languages) { idName = PREFIX_TEXTBOX + l.Code.ToString(); idPopupName = "ppp_" + l.Code.ToString(); ; ////////////////////////////////////////////////// ////////////////// Text Box ////////////////////// HtmlTableRow hr = new HtmlTableRow(); HtmlTableCell hc = new HtmlTableCell(); hc.Attributes.Add("style", "padding-bottom:2px; padding-top:2px;padding-right:2px;"); ASPxTextBox atb = new ASPxTextBox() { }; if (IsRequiredField) { atb.SetValidation(ValidationGroup); } atb.Width = Width; atb.ID = idName; atb.ClientInstanceName = this.ClientID + idName; hc.Controls.Add(atb); hr.Cells.Add(hc); tab.Rows.Add(hr); ab.Add(atb); ////////////////////////////////////////////////// ////////////////// Hint ////////////////////////// DevExpress.Web.ASPxPopupControl.PopupWindow pww = new DevExpress.Web.ASPxPopupControl.PopupWindow(); pww.Name = idPopupName; pww.Text = l.Code.ToString(); pww.PopupElementID = idName; pppHint.Windows.Add(pww); //pw.Add(pww); ////////////////////////////////////////////////// ////////////////// event ///////////////////////// atb.ClientSideEvents.GotFocus = @"function(s,e) { var hintWindow = " + pppHint.ClientInstanceName + @".GetWindowByName('" + pww.Name + @"'); " + pppHint.ClientInstanceName + @".ShowWindow(hintWindow); }"; atb.ClientSideEvents.LostFocus = @"function(s,e) { var hintWindow = " + pppHint.ClientInstanceName + @".GetWindowByName('" + pww.Name + @"'); " + pppHint.ClientInstanceName + @".HideWindow(hintWindow); }"; } }
protected override void CreateChildControls() { base.CreateChildControls(); tableCell = new HtmlTableCell(); tbxBankNumber.Width = this.setWidth; tbxBankNumber.MaxLength = this.setMaxLength; tableCell.Controls.Add(tbxBankNumber); tableRow.Cells.Add(tableCell); //tableCell = new HtmlTableCell(); //tableCell.Controls.Add(imgValidate); //tableCell.Controls.Add(cbValidate); //tableRow.Cells.Add(tableCell); table.CellPadding = 0; table.CellSpacing = 0; table.Rows.Add(tableRow); this.Controls.Add(table); //tbxBankNumber.NumberType = SpinEditNumberType.Integer; //tbxBankNumber.ToolTip = "กรุณาระบุจำนวนเลขที่บัญชี 10 หลัก หรือ 15 หลัก"; //imgValidate.ImageUrl = "~/Images/led_icon/cross.png"; tbxBankNumber.SetValidation(ValidationGroup, IsRequiredField, "(^([0-9]{10})$)|(^([0-9]{15})$)", "กรุณาระบุจำนวนเลขที่บัญชี 10 หลัก หรือ 15 หลัก"); tbxBankNumber.ClientInstanceName = (ClientInstanceName != null ? ClientInstanceName : tbxBankNumber.ClientID); //imgValidate.ClientInstanceName = (ImageClientInstanceName != null ? ImageClientInstanceName : imgValidate.ClientID); //cbValidate.ClientInstanceName = (callbackClientInstanceName != null ? callbackClientInstanceName : cbValidate.ClientID); //cbValidate.Callback += new CallbackEventHandler(cbValidate_Callback); #region javascript area tbxBankNumber.ClientSideEvents.KeyUp = @"function(s,e){ /*var a = s.GetText(); if( e.htmlEvent.keyCode == 8 ) { if( a.length == 10 || a.length == 15) {" + cbValidate.ClientInstanceName + @".SendCallback('no'); } } else { if( a.length == 9 || a.length == 14 || a.length == 15) {" + cbValidate.ClientInstanceName + @".SendCallback('ok'); } else {" + cbValidate.ClientInstanceName + @".SendCallback('no'); } }*/ " + tbxBankNumber.ClientInstanceName + @".Validate(); }"; // cbValidate.ClientSideEvents.CallbackComplete = @"function(s,e) // { // " + imgValidate.ClientInstanceName + @".SetImageUrl(e.result); // }"; #endregion javascript area }