How To Set Focus On Error In Asp.net
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up set focus on custom validator up vote 2 down vote favorite I have 2 textbox, one for login another for password. I have 1 custom server side validator too, if password is entered wrong, validator is fired. What I want is to set focus on this error message. I have tried focus(), and setfocusonerror property too. but its not working. here is my code:
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. MSDN Library MSDN Library MSDN Library MSDN Library Design Tools Development Tools and Languages Mobile and Embedded Development .NET Development Office development Online Services Open Specifications patterns & practices Servers and Enterprise Development Speech Technologies Web Development Windows Desktop App Development TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. How to: Set http://stackoverflow.com/questions/18251171/set-focus-on-custom-validator Focus on ASP.NET Web Server Controls Other Versions Visual Studio 2010 .NET Framework 4 Visual Studio 2008 .NET Framework 3.0 Visual Studio 2005 If it is important in your application, you can put the focus on a specific ASP.NET Web server control by using server code. You can put the focus on a specific control dynamically, or you can specify a control that should get the focus by default. You can set the default focus for the form https://msdn.microsoft.com/en-us/library/ms178232.aspx as a whole, or you can set the default focus on a control that is a child of a Panel control. You can put the focus on the following types of controls: Button, LinkButton, and ImageButton controls CheckBox control DropDownList control FileUpload control HyperLink control ListBox control RadioButton control TextBox control You can also set the focus on controls that contain one or more of the controls listed above. For example, you can set the focus on a Login control. In that case, the focus will be put on the first eligible control within the Login control. In general, if you set focus on a control that cannot receive focus or is hidden or disabled, the call is ignored. If you attempt to set focus on a non-visual control, such as a data source control, an exception is thrown. Note Setting focus requires that client scripting be enabled in the browser. To set focus on an ASP.NET Web server control Call the control's Focus method. -or- Call the page's SetFocus method, passing it the ID of the control on which you want to set focus. The following code example shows how to set the focus on the control with the ID TextBox1: Security Note This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not in
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.setfocusonerror(v=vs.110).aspx Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. System.Web.UI.WebControls BaseValidator Class BaseValidator Properties BaseValidator Properties SetFocusOnError Property SetFocusOnError Property SetFocusOnError Property AssociatedControlID Property ControlToValidate Property Display Property EnableClientScript Property Enabled Property ErrorMessage Property ForeColor Property how to IsUnobtrusive Property IsValid Property PropertiesValid Property RenderUplevel Property SetFocusOnError Property Text Property ValidationGroup Property TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. BaseValidator.SetFocusOnError Property .NET Framework (current version) Other Versions Visual Studio 2010 .NET Framework how to set 4 Visual Studio 2008 .NET Framework 3.5 .NET Framework 3.0 .NET Framework 2.0 Gets or sets a value that indicates whether focus is set to the control specified by the ControlToValidate property when validation fails.Namespace: System.Web.UI.WebControlsAssembly: System.Web (in System.Web.dll)Syntax C#C++F#VB Copy [ThemeableAttribute(false)] public bool SetFocusOnError { get; set; } Property Value Type: System.Booleantrue to set focus on the control specified by ControlToValidate when validation fails; otherwise, false. The default is false.RemarksUse the SetFocusOnError property to specify whether focus is automatically set to the control specified by the ControlToValidate property when this validation control fails. This allows the user to quickly update the appropriate control.If multiple validation controls fail and this property is set to true, the control specified in the ControlToValidate property for the first validation control receives focus.This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.Version Information.NET FrameworkAvailable since 2.0See AlsoControlToValidateBaseValidator ClassSystem.Web.UI.WebControls NamespaceReturn to top Show: Inherited Protected Print Exp