470,561 Members | 2,180 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,561 developers. It's quick & easy.

Problem Moving to Top of Page When Submit Fails Due to Validation

ASP.Net v1.1 & vb.net

Hi all,

I have a simple survey form with first name/last name text boxes at the
top. I have validators on these text boxes to ensure that something is
entered in them.

The form has a Submit button (asp:button) at the bottom and if the
validation has failed I want the form to return to the top, so that the
validation messages can be seen.

Could anyone please give me a code example of how to handle this?

I have tried using the click event in the code-behind page, but it
doesn't fire and I have tried putting an onclick event in the html code
e.g. <asp:button onclick="cmdSubmit_click"...> with the cmdSubmit_click
script setting focus to the first textbox, bt this gives me an error
when I try to run it:
BC30390: 'OfficeUsageSurvey._Default.Private Sub cmdSubmit_Click(sender
As Object, e As System.EventArgs)' is not accessible in this context
because it is 'Private'.

TIA for any help/advice.

Alan.

Nov 19 '05 #1
3 1288
try using button.Attributes.Add("onclick", "javascript: callFunction();
return false;");
"aljodo" <al************@armstrongwatson.co.uk> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
ASP.Net v1.1 & vb.net

Hi all,

I have a simple survey form with first name/last name text boxes at the
top. I have validators on these text boxes to ensure that something is
entered in them.

The form has a Submit button (asp:button) at the bottom and if the
validation has failed I want the form to return to the top, so that the
validation messages can be seen.

Could anyone please give me a code example of how to handle this?

I have tried using the click event in the code-behind page, but it
doesn't fire and I have tried putting an onclick event in the html code
e.g. <asp:button onclick="cmdSubmit_click"...> with the cmdSubmit_click
script setting focus to the first textbox, bt this gives me an error
when I try to run it:
BC30390: 'OfficeUsageSurvey._Default.Private Sub cmdSubmit_Click(sender
As Object, e As System.EventArgs)' is not accessible in this context
because it is 'Private'.

TIA for any help/advice.

Alan.

Nov 19 '05 #2
Thanks for that John.
I'm a bit of a newbie to this, does it just go in the page_load event
and what does it then allow me to do?

Thanks again.

Nov 19 '05 #3
Hi Alan,

The Microsoft validator controls cannot do this. I rewrote ASP.NET
validation to give it the features everyone has requested, including
solutions for this. My solution is called Professional Validation And More:
http://www.peterblum.com/vam/home.aspx.

You can set a property to have it set focus back to the first field with an
error when the submit button is clicked.
You can set a property to do the same when the user edits a field and its
incorrect.
My enhanced ValidationSummary control can offer hyperlinks on each error
message that when clicked, puts focus on the field associated with the
error.
My ValidationSummary has an option to scroll itself into view when you click
Submit.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"aljodo" <al************@armstrongwatson.co.uk> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
ASP.Net v1.1 & vb.net

Hi all,

I have a simple survey form with first name/last name text boxes at the
top. I have validators on these text boxes to ensure that something is
entered in them.

The form has a Submit button (asp:button) at the bottom and if the
validation has failed I want the form to return to the top, so that the
validation messages can be seen.

Could anyone please give me a code example of how to handle this?

I have tried using the click event in the code-behind page, but it
doesn't fire and I have tried putting an onclick event in the html code
e.g. <asp:button onclick="cmdSubmit_click"...> with the cmdSubmit_click
script setting focus to the first textbox, bt this gives me an error
when I try to run it:
BC30390: 'OfficeUsageSurvey._Default.Private Sub cmdSubmit_Click(sender
As Object, e As System.EventArgs)' is not accessible in this context
because it is 'Private'.

TIA for any help/advice.

Alan.

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by william c | last post: by
6 posts views Thread by MickG | last post: by
4 posts views Thread by Alan Silver | last post: by
2 posts views Thread by Darren Carter | last post: by
1 post views Thread by =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post: by
reply views Thread by =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post: by
11 posts views Thread by SAL | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.