Solved

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

Posted on 2012-03-21
3
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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