472,780 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 1368
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: william c | last post by:
I don't really know PHP that well. I'm fixing a Perl program that accesses a db after getting form input from a PHP page. If the server-side validation fails I'd like to reload the form with all...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
6
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is...
4
by: Alan Silver | last post by:
Hello, If you add (say) two text boxes to a form, then add a validator with some simple rule for one of them, you can observer the following problem:- Type some erroneous value in the text...
2
by: Jake Barnes | last post by:
Imagine I've this block of HTML: <p>Alex Schein Mailing List <input type="checkbox" name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"...
2
by: Darren Carter | last post by:
Hi, I have mutliple asp:Panel controls on a single page, each with a default button defined (each default button resides within its respective asp:Panel). All validation controls and buttons...
1
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation errors occur on the page. Background: My page...
0
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation errors occur on the page. Background: My page...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.