asp.net ValidationSummary location/focus - asp.net

I am using asp.net ValidationSummary. my form is 1.5 of the screen which means user can not see the complete form at a time and s/he has to scroll. The ValidationSummary is located at the bottom of the page. User is at the top of the page and error occurs then s/he won't be able to see the ValidationSummary because neither this control gets focus nor it makes the browser scroll down to show itself. The case is same if user is at the bottom of the page and ValidationSummary is at the top.
Please suggest how to show this ValidationSummary automatically ?

I find the validation summary isn't the most user friendly for long forms especially when scrolling appears.
Why not remove the validation summary and highlight the fields with the errors with a validation errror message beside the control and a visual idicator beside the submit button? This appraoch would be a lot mroe user friendly

Why don't you move the ValidationSummary to the top then?
Or just style the ValidationSummary.
This is a UI problem, not a technical one.

Related

Validator behavior inside ASCX

I have some input fields, regular expression validators, and custom validators inside an ASP.NET ASCX control. The behavior is a bit odd in that it works the following way:
If a client side validator flags an error message and I tab away from the input field and click submit then the page posts as it should. However, if a client side validator has flagged an error and instead I correct the error and click submit button then the error is cleared but the page is not submitted until I click the submit button a second time.
My question is how do I change this behavior such that I only need to click the submit button once to both clear the error and postback the page? Also, is this "behavior" standard?
Update: This behavior occurs without using the user control. I believe it is specific behavior to the CompareValidator. Nope, same behavior occurs with custom validator. If I don't "tab away" and click the button then I must click it twice to get the postback to occur. The first click just clears the validators.
The issue is that the CustomValidator has display type as Dynamic and not Static. This post helped me to discover the answer
RequiredFieldValidator have to click twice
I will give credit for anyone who explains why it causes this behavior.

Page does not move to top update panel inside user control

I have a user control on a ASP.NET page. Inside the user control there is a update panel. The page is a little lengthy and has Validation Summary control at the top.
The Submit button is at the bottom of the page. When I click the submit and when client side validation fails (on requiredfieldvalidators), the page DOES NOT move to the top where the Validation Summary control shows the messages. It just moves till the user control which is in the middle of the page.
I tried settings MaintainScrollPositionOnPostback="true" on the aspx page, but that didn't work.
How can I make it so when client-side validation fails, it moves to the top of the page?
Thanks
If the validation fails try to focus a control that is near the validation summary, maybe that work. ie. txtName.Focus(). If the validation is happening in the client side, try to do some js to detect when the summary appears....

ASP.NET - Still getting flicker despite using UpdatePanel

I have put several controls into an UpdatePanel. When I press the button inside the update panel there's no progress bar on the bottom status bar and there's no typical click sound that occurs during a normal postback. But the page still flickers to the top and I cannot see the validation errors. Could it be because I have a DataGrid on the update panel. I heard DataGrid and Updatepanel don't work well together.
Are you using any validation controls? I tend to add Validation controls but forget to assign the ErrorMessage text which often cuases me ponder why something isn't working.

ASP.NET - RequiredFieldValidator to validate only particular controls

I have a web form. There are many different sections. I can say that each section displays data of a datatable. At each section I have OK and Cancel buttons. When I press OK any changes to the table in the database takes place. I've also put some Requiredfieldvalidators. Let's say I'm inserting a new record in the section one and the fields are correctly typed. When I press OK I get error message raised by the rest of the validators that are on the other sections. Isn't there any way that when I press OK button of a particular section to get validation errors of that same area? So what I probably need is a button that will not serve as the hole page submitter but rather a submitter of a specific section.
Place a ValidationGroup on the RequiredFieldValidator's. Then place the same ValidationGroup on the correct submit button. When its clicked, only validation controls that are a part of the group are validated.
http://msdn.microsoft.com/en-us/library/ms227424.aspx
I think janhartmann is correct ValidationGroup can help you solve the issue.Have a look at this article

asp.net login layout and positioning

I'm using asp.net's login control; two textboxes with the labels on the left and a button beneath (the control renders as a table with 3 rows). When the user enters an incorrect login, the page is posted back and the failure text "incorrect login" is displayed by adding a row between the password textbox and the button.
The problem is that when the failure text is displayed, the new row that's inserted shifts the button down slightly.
It looks odd and off. How can I rearrange this so that when the failure text appears it doesn't shift the login button.
Thanks for your suggestions.
Check out the documentation for the Login control.
Assuming there isn't CSS or markup on the page causing the shifting, you should be able to control the style of the failure text via FailureTextStyle property.
Ok, if anyone gets to this page because of a layout problem with the login control, it's actually pretty easy to solve. By default, the control renders as a table and there's nothing you can do to change the layout of the default control because you don't have access to the HTML.
You need to switch the page to design mode and on the control, click "Convert to Template". When you go back to the source page, the HTML becomes accessible and you can see the HTML of the table that contains the various asp controls. Yank the table and put the control inside divs that you control!

Resources