当前位置: 首页>>代码示例>>C#>>正文


C# TextBox.Focus方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.TextBox.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.Focus方法的具体用法?C# TextBox.Focus怎么用?C# TextBox.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.TextBox的用法示例。


在下文中一共展示了TextBox.Focus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmptyTextBoxes

 public static void EmptyTextBoxes(System.Web.UI.Control parent, TextBox tb)
 {
     //Loop through all controls
     foreach (System.Web.UI.Control ctrControl in parent.Controls)
     {
         //Check to see if it's a textbox
         if (ctrControl.GetType() == typeof(TextBox))
         {
             //If it is then set the text to String.Empty (empty textbox)
             ((TextBox) ctrControl).Text = string.Empty;
             //Set the focus to the textbox you set in the call of the sub
             tb.Focus();
         }
         else if (ctrControl.GetType() == typeof(DropDownList)) //Next check if it's a dropdown list
         {
             //If it is then set its SelectedIndex to 0
             ((DropDownList) ctrControl).SelectedIndex = 0;
         }
         if (ctrControl.HasControls())
         {
             //Call itself to get all other controls in other containers
             //Note: Remove the argument tb if you have removed the ByVal tb As TextBox argument in the signature.
             EmptyTextBoxes(ctrControl, tb);
         }
     }
 }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:26,代码来源:TextSupport.cs

示例2: AddInfo

 public void AddInfo(TextBox txtBox, ListBox listBox, AddDelegate addMethod, GetDelegate getMethod)
 {
     string txt = txtBox.Text;
     int addCount = 0;
     DataSet ds;
     if (txt != "")
     {
         addCount = addMethod(txt);
         if (addCount <= 0)
         {
             MsgBox("该值已存在!");
         }
     }
     else
     {
         MsgBox("不能添加空值!");
     }
     listBox.Items.Clear();
     txtBox.Text = "";
     ds = getMethod();
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         listBox.Items.Add(ds.Tables[0].Rows[i][0].ToString());
     }
     txtBox.Focus();
 }
开发者ID:jurojinx,项目名称:LuxERP,代码行数:26,代码来源:FacilityManage.aspx.cs

示例3: ValidarTextBoxVacio

            public static bool ValidarTextBoxVacio(TextBox TextoValidar, string MensajedeError)
        {
            bool valido = true;

            if (TextoValidar.Text.Trim().Length == 0)
            {
                TextoValidar.Focus();
                valido = false;
            }

            return valido;

        }
开发者ID:chrisgenao,项目名称:Tarea-1-Aplicada-2,代码行数:13,代码来源:Utilitarios.cs

示例4: IsNullOrEmpty

 /// <summary>
 /// 验证是否为null或string.Empty
 /// </summary>
 /// <param name="value"></param>
 /// <param name="title"></param>
 /// <returns></returns>
 public static void IsNullOrEmpty(TextBox textBox, string title, ref bool isContinue, ref string errorMsg)
 {
     string value = textBox.Text.Trim();
     if (isContinue)
     {
         if (value == null || value.Trim() == string.Empty)
         {
             errorMsg = string.Format("{0}不可为空!", title);
             isContinue = false;
             textBox.Focus();
         }
     }
     errorMsg = isContinue ? string.Empty : errorMsg;
 }
开发者ID:cityjoy,项目名称:CommonToolkit,代码行数:20,代码来源:RegexMode.cs

示例5: GetAutomaticDropDownList

 protected void GetAutomaticDropDownList(TextBox textCode, DropDownList dropDownSource)
 {
     ListItem item = dropDownSource.Items.FindByValue(textCode.Text);
     if (item != null)
     {
         dropDownSource.SelectedValue = textCode.Text;
     }
     else
     {
         dropDownSource.SelectedIndex = 0;
         textCode.Text = dropDownSource.SelectedValue;
         textCode.Focus();
     }
 }
开发者ID:dtafe,项目名称:WorkNC,代码行数:14,代码来源:WorkNCPortalModuleBase.cs

示例6: AttachChildControls

        protected override void AttachChildControls()
        {
            if (Context.Request.IsAuthenticated)
            {
                FormsAuthentication.SignOut();
                HttpCookie authCookie = FormsAuthentication.GetAuthCookie(HiContext.Current.User.Username, true);
                IUserCookie userCookie = HiContext.Current.User.GetUserCookie();
                if (userCookie != null)
                {
                    userCookie.DeleteCookie(authCookie);
                }
                RoleHelper.SignOut(HiContext.Current.User.Username);
            }
            if (!string.IsNullOrEmpty(Page.Request["action"]) && (Page.Request["action"] == "Common_UserLogin"))
            {
                string str = UserLogin(Page.Request["username"], Page.Request["password"]);
                string str2 = string.IsNullOrEmpty(str) ? "Succes" : "Fail";
                Page.Response.Clear();
                Page.Response.ContentType = "application/json";
                Page.Response.Write("{\"Status\":\"" + str2 + "\",\"Msg\":\"" + str + "\"}");
                Page.Response.End();
            }
            txtUserName = (TextBox) FindControl("txtUserName");
            txtPassword = (TextBox) FindControl("txtPassword");
            btnLogin = ButtonManager.Create(FindControl("btnLogin"));
            ddlPlugins = (DropDownList) FindControl("ddlPlugins");
            if (ddlPlugins != null)
            {
                ddlPlugins.Items.Add(new ListItem("请选择登录方式", ""));
                IList<OpenIdSettingsInfo> configedItems = MemberProcessor.GetConfigedItems();
                if ((configedItems != null) && (configedItems.Count > 0))
                {
                    foreach (OpenIdSettingsInfo info in configedItems)
                    {
                        ddlPlugins.Items.Add(new ListItem(info.Name, info.OpenIdType));
                    }
                }
                ddlPlugins.SelectedIndexChanged += new EventHandler(ddlPlugins_SelectedIndexChanged);
            }

            if ( Page.Request.UrlReferrer != null &&!string.IsNullOrEmpty(Page.Request.UrlReferrer.OriginalString))
            {
                ReturnURL = Page.Request.UrlReferrer.OriginalString;
            }

            txtUserName.Focus();
            PageTitle.AddSiteNameTitle("用户登录", HiContext.Current.Context);
            btnLogin.Click += new EventHandler(btnLogin_Click);
        }
开发者ID:davinx,项目名称:himedi,代码行数:49,代码来源:Login.cs

示例7: CheckInputEmptyAndLength

        protected bool CheckInputEmptyAndLength(TextBox txtName, string EmptyErrorCode, string ExceedErrorCode, bool DoubleChar)
        {
            if (String.IsNullOrEmpty(txtName.Text))
            {
                SetMessage(GetMessage(EmptyErrorCode, txtName.MaxLength.ToString()));
                txtName.Focus();
                return false;
            }

            //VarChar
            if (DoubleChar == true && StringHelper.GetLengthByByte(txtName.Text) > txtName.MaxLength)
            {
                SetMessage(GetMessage(ExceedErrorCode, txtName.MaxLength.ToString()));
                txtName.Focus();
                return false;
            }

            //NVarChar
            if (DoubleChar == false && StringHelper.GetLength(txtName.Text) > txtName.MaxLength)
            {
                SetMessage(GetMessage(ExceedErrorCode, txtName.MaxLength.ToString()));
                txtName.Focus();
                return false;
            }

            return true;
        }
开发者ID:jojozhuang,项目名称:Projects,代码行数:27,代码来源:AdminAuth.cs

示例8: Focus_Load

		public static void Focus_Load (Page p)
		{
			TextBox tbx = new TextBox ();
			tbx.ID = "TestBox";
			p.Controls.Add (tbx);
			tbx.Focus ();
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:ControlTest.cs

示例9: SetEndTime

        public void SetEndTime(TextBox txtst_time, TextBox txtend_time)
        {
            bool b = CheckDate(txtst_time.Text);
            if (b == false)
            {
                return;
            }
            DateTime stime = Convert.ToDateTime(txtst_time.Text);
            TimeSpan t = new TimeSpan(3, 0, 0);
            DateTime etime = stime + t;

            txtend_time.Text = etime.ToString("t");
            txtend_time.Focus();
        }
开发者ID:NetworksAuro,项目名称:Networks,代码行数:14,代码来源:EngagementSchedule.aspx.cs

示例10: DisplayNeueZutatenListeEingaben

        private void DisplayNeueZutatenListeEingaben(Panel rezeptAbteilungPanel, int zutatenAnzahl)
        {
            using (var db = new rherzog_70515_rzvwContext())
            {
                //Name
                var textbox = new TextBox { ID = Helper.REZEPBEARBEITEN_IDENT_ZUTAT + Helper.REZEPBEARBEITEN_IDENT_NEU + rezeptAbteilungPanel.ID + zutatenAnzahl, Text = string.Empty, Width = RezeptNameFeldBreite };
                rezeptAbteilungPanel.Controls.Add(textbox);
                textbox.Focus();

                //Menge
                textbox = new TextBox { ID = Helper.REZEPBEARBEITEN_IDENT_MENGE + Helper.REZEPBEARBEITEN_IDENT_NEU + rezeptAbteilungPanel.ID + zutatenAnzahl, Text = string.Empty, Width = RezeptMengeFeldBreite };
                rezeptAbteilungPanel.Controls.Add(textbox);

                //Einheit
                var dropdownlist = new DropDownList { ID = Helper.REZEPBEARBEITEN_IDENT_EINHEIT + Helper.REZEPBEARBEITEN_IDENT_NEU + rezeptAbteilungPanel.ID + zutatenAnzahl, Width = RezeptEinheitFeldBreite };
                //leerer Eintrag
                var listItem = new ListItem(string.Empty, string.Empty);
                dropdownlist.Items.Add(listItem);
                foreach (var item in db.Einheits)
                {
                    listItem = new ListItem(item.Bezeichnung, item.ID.ToString(CultureInfo.InvariantCulture));
                    dropdownlist.Items.Add(listItem);
                }
                rezeptAbteilungPanel.Controls.Add(dropdownlist);

                //Zeilenumbruch
                var literalPageBreak = new Literal {Text = "<br/>"};
                rezeptAbteilungPanel.Controls.Add(literalPageBreak);
            }
        }
开发者ID:rgherzog,项目名称:RezeptVerwaltung,代码行数:30,代码来源:RezeptBearbeiten.aspx.cs

示例11: PopulateControls

        private void PopulateControls()
        {
            LoginCtrl.SetRedirectUrl = setRedirectUrl;

            lblUserID = (Label)this.LoginCtrl.FindControl("lblUserID");
            //lblEmail = (SiteLabel)this.LoginCtrl.FindControl("lblEmail");
            txtUserName = (TextBox)this.LoginCtrl.FindControl("UserName");
            txtPassword = (TextBox)this.LoginCtrl.FindControl("Password");
            chkRememberMe = (CheckBox)this.LoginCtrl.FindControl("RememberMe");
            btnLogin = (LinkButton)this.LoginCtrl.FindControl("Login");
            lnkRecovery = (HyperLink)this.LoginCtrl.FindControl("lnkPasswordRecovery");
            lnkExtraLink = (HyperLink)this.LoginCtrl.FindControl("lnkRegisterExtraLink");

            divCaptcha = (Panel)LoginCtrl.FindControl("divCaptcha");
            //captcha = (CaptchaControl)LoginCtrl.FindControl("captcha");
            //if (!siteSettings.RequireCaptchaOnLogin)
            //{
            //    if (divCaptcha != null) { divCaptcha.Visible = false; }
            //    if (captcha != null) { captcha.Captcha.Enabled = false; }
            //}
            //else
            //{
            //    captcha.ProviderName = siteSettings.CaptchaProvider;
            //    captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
            //    captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;

            //}

            //if ((siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
            //{
            //    if (!WebConfigSettings.AllowLoginWithUsernameWhenSiteSettingIsUseEmailForLogin)
            //    {
            //        RegularExpressionValidator regexEmail = new RegularExpressionValidator();
            //        regexEmail.ControlToValidate = txtUserName.ID;
            //        //regexEmail.ValidationExpression = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
            //        regexEmail.ValidationExpression = SecurityHelper.RegexEmailValidationPattern;
            //        regexEmail.ErrorMessage = Resource.LoginFailedInvalidEmailFormatMessage;
            //        this.LoginCtrl.Controls.Add(regexEmail);
            //    }

            //}

            //if (siteSettings.UseEmailForLogin && !siteSettings.UseLdapAuth)
            //{
            //    this.lblUserID.Visible = false;
            //}
            //else
            //{
            //    this.lblEmail.Visible = false;
            //}

            if (setFocus)
            {
                txtUserName.Focus();
            }

            lnkRecovery.Visible = false;// ((siteSettings.AllowPasswordRetrieval || siteSettings.AllowPasswordReset) && (!siteSettings.UseLdapAuth ||
            //                                   (siteSettings.UseLdapAuth && WebConfigSettings.UseLDAPFallbackAuthentication)));

            lnkRecovery.NavigateUrl = this.LoginCtrl.PasswordRecoveryUrl;
            lnkRecovery.Text = this.LoginCtrl.PasswordRecoveryText;

            lnkExtraLink.NavigateUrl = siteRoot + "/Secure/Register.aspx";
            lnkExtraLink.Text = "Đăng ký";//Resource.RegisterLink;
            lnkExtraLink.Visible = false;// siteSettings.AllowNewRegistration;

            string returnUrlParam = Page.Request.Params.Get("returnurl");
            if (!String.IsNullOrEmpty(returnUrlParam))
            {
                //string redirectUrl = returnUrlParam;
                lnkExtraLink.NavigateUrl += "?returnurl=" + returnUrlParam;
            }

            chkRememberMe.Visible = true;// WebConfigSettings.AllowPersistentLoginCookie;
            chkRememberMe.Text = this.LoginCtrl.RememberMeText;

            btnLogin.Text = this.LoginCtrl.LoginButtonText;
            //SiteUtils.SetButtonAccessKey(btnLogin, AccessKeys.LoginAccessKey);
        }
开发者ID:thanhdai18ht,项目名称:BOEDU,代码行数:79,代码来源:ControlLogin.ascx.cs

示例12: PopulateControls

        private void PopulateControls()
        {
            if (siteSettings == null) { return; }
            if (siteSettings.DisableDbAuth) { this.Visible = false; return; }

            LoginCtrl.SetRedirectUrl = setRedirectUrl;

            lblUserID = (SiteLabel)this.LoginCtrl.FindControl("lblUserID");
            lblEmail = (SiteLabel)this.LoginCtrl.FindControl("lblEmail");
            txtUserName = (TextBox)this.LoginCtrl.FindControl("UserName");
            txtPassword = (TextBox)this.LoginCtrl.FindControl("Password");
            chkRememberMe = (CheckBox)this.LoginCtrl.FindControl("RememberMe");
            btnLogin = (mojoButton)this.LoginCtrl.FindControl("Login");
            lnkRecovery = (HyperLink)this.LoginCtrl.FindControl("lnkPasswordRecovery");
            lnkExtraLink = (HyperLink)this.LoginCtrl.FindControl("lnkRegisterExtraLink");

            if (WebConfigSettings.DisableAutoCompleteOnLogin)
            {
                txtUserName.AutoCompleteType = AutoCompleteType.Disabled;
                txtPassword.AutoCompleteType = AutoCompleteType.Disabled;
            }

            divCaptcha = (Panel)LoginCtrl.FindControl("divCaptcha");
            captcha = (CaptchaControl)LoginCtrl.FindControl("captcha");
            if (!siteSettings.RequireCaptchaOnLogin)
            {
                if (divCaptcha != null) { divCaptcha.Visible = false; }
                if (captcha != null) { captcha.Captcha.Enabled = false; }
            }
            else
            {
                captcha.ProviderName = siteSettings.CaptchaProvider;
                captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
                captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;

            }

            if ((siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
            {
                if (!WebConfigSettings.AllowLoginWithUsernameWhenSiteSettingIsUseEmailForLogin)
                {
                    EmailValidator regexEmail = new EmailValidator();
                    regexEmail.ControlToValidate = txtUserName.ID;
                    regexEmail.ErrorMessage = Resource.LoginFailedInvalidEmailFormatMessage;
                    this.LoginCtrl.Controls.Add(regexEmail);
                }

            }

            if (siteSettings.UseEmailForLogin && !siteSettings.UseLdapAuth)
            {
                this.lblUserID.Visible = false;
            }
            else
            {
                this.lblEmail.Visible = false;
            }

            if (setFocus) { txtUserName.Focus(); }

            lnkRecovery.Visible = ((siteSettings.AllowPasswordRetrieval ||siteSettings.AllowPasswordReset) && (!siteSettings.UseLdapAuth ||
                                                                           (siteSettings.UseLdapAuth && siteSettings.AllowDbFallbackWithLdap)));

            lnkRecovery.NavigateUrl = this.LoginCtrl.PasswordRecoveryUrl;
            lnkRecovery.Text = this.LoginCtrl.PasswordRecoveryText;

            lnkExtraLink.NavigateUrl = siteRoot + "/Secure/Register.aspx";
            lnkExtraLink.Text = Resource.RegisterLink;
            lnkExtraLink.Visible = siteSettings.AllowNewRegistration;

            string returnUrlParam = Page.Request.Params.Get("returnurl");
            if (!String.IsNullOrEmpty(returnUrlParam))
            {
                //string redirectUrl = returnUrlParam;
                lnkExtraLink.NavigateUrl += "?returnurl=" + SecurityHelper.RemoveMarkup(returnUrlParam);
            }

            chkRememberMe.Visible = siteSettings.AllowPersistentLogin;
            chkRememberMe.Text = this.LoginCtrl.RememberMeText;

            if (WebConfigSettings.ForcePersistentAuthCheckboxChecked)
            {
                chkRememberMe.Checked = true;
                chkRememberMe.Visible = false;
            }

            btnLogin.Text = this.LoginCtrl.LoginButtonText;
            //SiteUtils.SetButtonAccessKey(btnLogin, AccessKeys.LoginAccessKey);
        }
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:89,代码来源:LoginControl.ascx.cs

示例13: ShowMessage

 private void ShowMessage(String Message, Label Label, TextBox TextBox)
 {
     Label.Text = Message;
     TextBox.Focus();
 }
开发者ID:crvhavefun,项目名称:allinone,代码行数:5,代码来源:Default.aspx.cs

示例14: CreateChildControls

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            _ctrlWrappers = new Panel {ID = "wrp", CssClass = "controlWrappers"};
            _ctrlWrappers.Style[Styles.opacity] = "0.3";
            Controls.Add(_ctrlWrappers);

            BehaviorUnveiler unveiler = new BehaviorUnveiler {ID = "unveiler"};
            _ctrlWrappers.Controls.Add(unveiler);

            _filterWrapper = new Panel {ID = "fltW", DefaultWidget = "fltB"};

            _filter = new TextBox {ID = "flt", CssClass = "filter"};

            _fltBtn = new Button {ID = "fltB"};
            _fltBtn.Style[Styles.marginLeft] = "-1000px";
            _fltBtn.Click += 
                delegate
                {
                    // Making sure we select all "filter text" to mak it easy to "re-filter"...
                    _filter.Focus();
                    _filter.Select();

                    // Checking for dead keys...
                    if (OldFilter != _filter.Text)
                    {
                        CurrentPage = 0;
                        DataBindGrid();
                        _lstWrappers.ReRender();
                        _lstWrappers.Style[Styles.display] = "none";
                        new EffectFadeIn(_lstWrappers, 200)
                            .Render();
                        OldFilter = _filter.Text;
                    }
                };
            _filterWrapper.Controls.Add(_filter);
            _filterWrapper.Controls.Add(_fltBtn);
            _ctrlWrappers.Controls.Add(_filterWrapper);

            _previous = new LinkButton {ID = "prev", Text = "&nbsp;", CssClass = "previous"};
            _previous.Text = "&lt;&lt;";
            _previous.Click +=
                delegate
                {
                    if (CurrentPage != 0)
                    {
                        CurrentPage -= 1;
                        DataBindGrid();
                        _lstWrappers.ReRender();
                        new EffectRollUp(_lstWrappers, 200)
                            .ChainThese(
                                new EffectFadeIn(_lstWrappers, 200))
                            .Render();
                    }
                };
            _ctrlWrappers.Controls.Add(_previous);

            _count = new Label {ID = "cnt", CssClass = "count"};
            _ctrlWrappers.Controls.Add(_count);

            _next = new LinkButton {ID = "next", Text = "&nbsp;", CssClass = "next"};
            _next.Text = "&gt;&gt;";
            _next.Click +=
                delegate
                {
                    if ((CurrentPage + 1) * PageSize < DataSource["Rows"].Count)
                    {
                        CurrentPage += 1;
                        DataBindGrid();
                        _lstWrappers.ReRender();
                        new EffectRollUp(_lstWrappers, 200)
                            .ChainThese(
                                new EffectFadeIn(_lstWrappers, 200))
                            .Render();
                    }
                };
            _ctrlWrappers.Controls.Add(_next);

            _lstWrappers = new Panel {ID = "lstWrp", CssClass = "gridWrapper"};
            Controls.Add(_lstWrappers);
        }
开发者ID:greaterwinner,项目名称:ra-brix,代码行数:82,代码来源:Grid.cs

示例15: RegexValidate

 /// <summary>
 /// 正则验证(注意:第一句验证,isContinue需设置为true)
 /// </summary>
 /// <param name="value">要验证的值</param>
 /// <param name="title">错误消息标题</param>
 /// <param name="validateEmpty">数据为空字符时是否验证</param>
 /// <param name="regexMode">验证模式</param>
 /// <param name="isContinue">是否继续验证</param>
 /// <param name="errorMsg">验证失败显示的消息</param>
 /// <returns></returns>
 public static void RegexValidate(TextBox textBox, string title, bool validateEmpty, RegexMode regexMode, ref bool isContinue, ref string errorMsg)
 {
     if (isContinue && validateEmpty)
     {
         isContinue = Regex.IsMatch(textBox.Text.Trim(), RegexPrecept(regexMode, title, ref errorMsg));
         if (!isContinue) { textBox.Focus(); }
     }
     errorMsg = isContinue ? string.Empty : errorMsg;
 }
开发者ID:cityjoy,项目名称:CommonToolkit,代码行数:19,代码来源:RegexMode.cs


注:本文中的System.Web.UI.WebControls.TextBox.Focus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。