ASP.Net Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 2367 Page Views: 

How to set the cursor focus on a control in ASP.Net?



Posted By: Avi Date: 30 November 2009 04:53:44 AM
 Answer:

In ASP.Net 2.0, the cursor focus on a control can be set by using the Focus() method.
For example:
txtTest.Focus();

You can also set the focus of a control through the SetFocus() method of the Page class. The syntax is:

Page.SetFocus(controlName);

Apart from this you can use defaultfocus attribute to set the control that will be assigned the focus when the form is loaded.

<form id="aspform1" runat="server"
defaultfocus="txtName">

In earlier versions of ASP.Net, assigning focus to a control involves writing client-side script in JavaScript.


Posted By: eTechPlanet


Date: 30 November 2009 04:53:44 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image QGtS2a
Related Questions
ASP.Net : What is the use of AutoEventWireup attribute in Page directive?

What is the use of AutoEventWireup attribute in Page directive?

If the value of AutoEventWireup attribute is set to false, then you need to hook up events to events....
Category: ASP.Net Date: 9/25/2009 5:06:42 AM
ASP.Net : What is the difference between authentication and authorization?

What is the difference between authentication and authorization?

Authentication is the process of identifying users based on their credentials, i.e. user names and p....
Category: ASP.Net Date: 9/12/2009 7:38:46 AM
ASP.Net : What is ASP.Net server control?

What is ASP.Net server control?

ASP.Net server control is a control that is programmable by writing server-side code to respond to e....
Category: ASP.Net Date: 9/12/2009 7:09:29 AM
ASP.Net : Which object is used to share variables across all the users in an ASP.Net web application?
ASP.Net : What is Web Service Description Language (WSDL)?

What is Web Service Description Language (WSDL)?

Web Service description language (WSDL) is basically an XML document which describes the web service....
Category: ASP.Net Date: 8/29/2009 7:43:21 AM