本文整理汇总了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);
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例8: Focus_Load
public static void Focus_Load (Page p)
{
TextBox tbx = new TextBox ();
tbx.ID = "TestBox";
p.Controls.Add (tbx);
tbx.Focus ();
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
示例13: ShowMessage
private void ShowMessage(String Message, Label Label, TextBox TextBox)
{
Label.Text = Message;
TextBox.Focus();
}
示例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 = " ", CssClass = "previous"};
_previous.Text = "<<";
_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 = " ", CssClass = "next"};
_next.Text = ">>";
_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);
}
示例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;
}