Solved

How to set the focus to a field in a web form from another Web form

Posted on 2012-03-21
3
320 Views
Last Modified: 2012-03-21
Hi Everyone,

I am new to web forms.  I have created a web form that contains Event Buttons.  When I select the Person of Interest Event Button, I am re-directed to the Person of Interest data entry web form with this coding:  Response.Redirect("./IssueAdmin.aspx").  I need for the cursor to be flashing inside the PK_DriverLicenseID_vch field in the Person of Interest Web data entry form automatically.

How can I tell the computer to set the focus to the PK_DriverLicenseID_vch field in this web form without the user selecting the field?

jjc9809
0
Comment
Question by:jjc9809
3 Comments
 
LVL 38

Assisted Solution

by:PaulHews
PaulHews earned 167 total points
ID: 37747384
You can use javascript, calling .focus() on the element in a script that is run when the document is loaded...  This is pretty trivial in jquery if you are using that library.


You can also do it from server side by calling a Focus method or setting the defaultfocus for the form:

How to: Set Focus on ASP.NET Web Server Controls
http://msdn.microsoft.com/en-us/library/ms178232.aspx
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
ID: 37747390
0
 
LVL 19

Accepted Solution

by:
NerdsOfTech earned 167 total points
ID: 37747414
You could use any supported client-side language such as javascript to focus on the field. Here I will show  the example in Javascript.

Javascript:
<script language="javascript">
function focusMain(){
 var txtMain = document.getElementById('PK_DriverLicenseID_vch');
 txtMain.focus();
}
</script>

Open in new window


HTML:
<body onload="focusMain();">

Open in new window

...
<input type="text" name="PK_DriverLicenseID_vch" id="PK_DriverLicenseID_vch">

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now