?
Solved

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

Posted on 2012-03-21
3
Medium Priority
?
328 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 668 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 664 total points
ID: 37747390
0
 
LVL 19

Accepted Solution

by:
NerdsOfTech earned 668 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

741 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