473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Set focus on a text box

Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.

Regards,
Swami
Nov 18 '05 #1
3 1129
One way is to handle the onBlur event of the text box:

<asp:TextBox runat="server" id="txt" onblur="if (this.value.replace(/\s/g,
'').length == 0) this.focus();">

"Swami" <Sw***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.

Regards,
Swami
Nov 18 '05 #2
The easiest, most reliable way is client side javascript:

MyControl.focus();

Here's more info:
http://wp.netscape.com/eng/mozilla/3..._f-g.htm#59872

You might also consider using this free control:
http://www.metabuilders.com/Tools/FirstFocus.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Swami" <Sw***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
Dear All,
I have developed a aspx web page with c# as page language. I have place
two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box
apart
from displaying the error message. Please help.

Regards,
Swami

Nov 18 '05 #3
Check out this code snippet,
http://www.extremeexperts.com/Net/Co...rPostback.aspx

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Swami" <Sw***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
Dear All,
I have developed a aspx web page with c# as page language. I have place two text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart from displaying the error message. Please help.

Regards,
Swami

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scott Navarre | last post by:
Hi, I have Red Hat 8.0 and have the default Mozilla browser that comes with it. I am programming in javascript and have come across something problematic. Given the following code: <HTML>...
3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
9
by: Roger Withnell | last post by:
Tearing hair out time! Simple attached page shows the problem. http://www.brilley.co.uk/TestFocusSelect.htm Using a function to test if too many characters have been keyed in to a textarea....
2
by: Peter Wright | last post by:
Hi all. Hopefully this should demonstrate the problem I'm having: http://flooble.net/~pete/focus-problem-demo/ (I'm testing it in Mozilla only, but I'm not sure if it's actually a...
3
by: VA | last post by:
t=document.getElementById('mytable') is a HTML table with some input fields in its cells Why doesnt t.getElementsByTagName('tr').firstChild.focus; put the focus on that text field? It...
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
4
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
5
by: LabGeek | last post by:
I have an Access application that I have created that collects data from a scanner and from a weighting scale. The data from the scanner are unique identifiers (barcodes) and the scanner is...
11
by: sheldonlg | last post by:
I have a problem with not seeing the current focus while in a particular screen in a my app. The focus does not show for a type=text or textarea. I have tried to reproduce this problem in a test...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.