Search:
Namespaces
Discussions
.NET v1.1
Feedback
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...
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com