.NETGURU
Setting focus in control
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngbeta' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Mohan Deep Singh
    Hi All,

    I'm using the ValidatorSummary control in my web forms. I want to
set focus in the first control in my form where there is some error. Like we
use to do when using javascript in ASP.

    Regards,

    Deep

Reply to this message...
 
    
Michael Gaertner (VIP)
If your validation happens on the client side, you still need to set focus
with JavaScript. If a round trip is involved, I *think* you still need to
set focus with JavaScript via the BODY onload event. You probably already
have this code, but here it is anyway for BODY onload:

<script language="JavaScript">
function setFocus()
{
    with ( document.all ) {

            BPTMLogin_Email.focus()
    }
}

</script>

<body onload="setFocus()">

Good luck.

Michael

-----Original Message-----
From: Mohan Deep Singh [mailto:Click here to reveal e-mail address]
Sent: Tuesday, May 08, 2001 7:03 AM
To: aspngbeta
Subject: [aspngbeta] Setting focus in control

    Hi All,

    I'm using the ValidatorSummary control in my web forms. I want to
set focus in the first control in my form where there is some error. Like we
use to do when using javascript in ASP.

    Regards,

    Deep

| [aspngbeta] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngbeta.asp = JOIN/QUIT

Reply to this message...
 
    
Mohan Deep Singh
thanx, but problem is not with the javascript, that i'm writing from last
three years.

problem is how to do this while using the validator controls?? how to find
the first error and then set focus [i'm not using javascript ne where]

[Original message clipped]

Reply to this message...
 
    
Anthony Moore
I have a sample that does this. Here is the javascript routine that does
it:

<script language=3D"javascript">
function CustomOnSubmit() {
if (typeof(Page_ValidationActive) !=3D "undefined" &&
Page_ValidationActive =3D=3D true && !Page_IsValid) {
var i;
for (i =3D 0; i < Page_Validators.length; i++) {
var control =3D Page_Validators[i];
if (!control.isvalid) {
if (typeof(control.JumpTo) !=3D "undefined") {
document.all[control.JumpTo].scrollIntoView();
return;
}
}
}
vs1.scrollIntoView();
}
}
</script>

The other plubing required is (a) put CustomOnSubmit into the form
"onsubmit" event and (b) I used an expando on the validators to
reference an <a> tag to scroll to.

Anthony Moore

-----Original Message-----
From: Mohan Deep Singh [mailto:Click here to reveal e-mail address]
Sent: Tuesday, May 08, 2001 9:19 PM
To: aspngbeta
Subject: [aspngbeta] RE: Setting focus in control

thanx, but problem is not with the javascript, that i'm writing from
last
three years.

problem is how to do this while using the validator controls?? how to
find
the first error and then set focus [i'm not using javascript ne where]

[Original message clipped]

| [aspngbeta] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngbeta.asp =3D JOIN/QUIT

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification