Want page to post back and display error msgs on page

I have a long page with lots of fields. User has to scroll up and down. This is an Apply-For-A-Job page. I have Personal Info, resume, employer, etc sections.
I have those sections wrapped in an UpdatePanel.

*** For required fields, I have the RequiredFieldValidator. Displays a star next to each required field when it's missing.

At the bottom of the page, I have a submit button. It is NOT wrapped in an updatePanel.

*** This is what happens; when I click submit, Page doesnt go to the top ( I dont think it posts back) , I have to scroll up and then see the validator's "red stars" for missing fields.

*** This is what I want to do: When clicking submit,
  a. I want the page to post back ( i have the submit button outside UpdatePanel),
  b. ***go to the top of the page ***
  c. Still show validator's red stars
  d. Display a list of fields that were missing inline, on the page.

I think having the requiredFieldValidators is preventing the page from posting back and going to the top of the page. If I remove them, then I think i have to do *the validation in the code-behind* and display the error msg in a label something on top of the page. But then,i think i also have to display the requiredfieldvalidator red-star dynamically... OR do I need to have a validationGroup for all the validators on the page?

What to do?
//submit button

  <asp:Button runat="server" CssClass="formBUTTON" ID="btnSumbit" 
                Text="Submit Application"  Enabled="false"   tabindex="71" onclick="btnSumbit_Click" />

//textbox with validator
 <asp:TextBox  runat="server" ID="txtFirst_name" CssClass="formFIELD" TabIndex ="1"></asp:TextBox>
                   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtFirst_Name" ErrorMessage="First Name" Text="*" runat="server"/>
                   

Open in new window

LVL 8
CamilliaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Todd GerbertIT ConsultantCommented:
Update panels are used specifically to prevent a full round-trip postback.  If you don't want partial-page updates, and do want a full round-trip postback, don't use the update panels.

Or, use the OnClientClick of your submit button to run client-side javascript to scroll to the top of the page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun KlineLead Software EngineerCommented:
Try using the ValidatorSummary control. It will display the ErrorMessage property for any validator that fails.
0
CamilliaAuthor Commented:
I have the update panels because I have a Telerik Calendar. When I click on that calendar and choose a data, page does it a postback and I wanted to avoid that. Otherwise, now that i think about it, the rest of the controls on the page are textboxes and some radiobuttons, couple of dropdownlists.. ( I do a post back for ddl as well)...

Didnt even think about the ValidatorSummary. So use ValidatorSummary BUT also remove the UpdatePanel??
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

CamilliaAuthor Commented:
I had AutoPostBack for the Telerik Calendar, i dont think i need that either...
0
Todd GerbertIT ConsultantCommented:
Instead of wrapping EVERYTHING inside an UpdatePanel, just put the few controls that you want partial-page updates for inside UpdatePanel's.

Is your Submit button configured as a trigger for the UpdatePanel?
0
CamilliaAuthor Commented:
>>Is your Submit button configured as a trigger for the UpdatePanel?
I have 2 submit buttons. One to Upload a resume using Telerik's RadUpload control. For that to work, i have this:


<?xml:namespace prefix = asp />



** for the actual Sumbit Application button, I dont have it triggred. I just have it as above post.

-- You'e right, i dont need to wrap everything in an update panel. I have the ValidatorSummary now, going to remove the update panels.
Do I need to have a trigger for my submit Application button?
0
Todd GerbertIT ConsultantCommented:
Triggers of the UpdatePanel cause a partial-page update.  If you want a full round-trip post-back, then it should not be a trigger.
0
CamilliaAuthor Commented:
Copying and pasting caused that "<?xml:namespave prefix= asp/> to happen. Not sure why the post did it..

Yes, having updatepanel is not a good idea.Removing it now and just having it for sections i need...

So, do I still need to trigger the submit button application Button??
0
CamilliaAuthor Commented:
ok, just saw your msg above about trigges... Let me try this and will post back
0
guru_samiCommented:
*** This is what happens; when I click submit, Page doesnt go to the top ( I dont think it posts back) , I have to scroll up and then see the validator's "red stars" for missing fields.

did you try setting SetFocusOnError="true" - property for the asp.net validation controls...
It will set the focus to the first failed validator targetcontrol.
0
CamilliaAuthor Commented:
guru - nope, i hadnt done that. But still, i think having everything wrapped in an UpdatePanel is too much. Let me try what you said and what tg said.

ValidationSummary is working great.
0
CamilliaAuthor Commented:
One question:

I removed updatepanels but i have to have it for a radiobutton list. I dont want the page to show the postback.

I have the below code. I click on one of the radiobutton lists, it should postback and display/hide a panel but it doesnt.

ValidationSummary and going to the top of the page to display the error works great now. I just need to get this one working.
 <asp:UpdatePanel runat="server" >
       <ContentTemplate>
       
      
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td>
             <asp:RadioButtonList AutoPostBack="true"  runat="server" TextAlign="Right" RepeatDirection="Horizontal" OnSelectedIndexChanged="OnSelectedIndexChanged_rbLoadPasteResume"  ID="rbLoadPasteResume">
               <asp:ListItem Value="U" Text="Upload Resume"></asp:ListItem>
               <asp:ListItem Value="P" Text="Paste Resume"></asp:ListItem>
             </asp:RadioButtonList><br />
          </td>
           <td>
           <asp:RequiredFieldValidator ControlToValidate="rbLoadPasteResume" Text="*" ErrorMessage="Upload Or Paste Resume" ForeColor="Red" runat="server"></asp:RequiredFieldValidator>
          </td>
          <td></td>
          </tr>
          </table>
         
         </ContentTemplate>
      </asp:UpdatePanel>

Open in new window

0
Shaun KlineLead Software EngineerCommented:
Try adding an AsyncPostBackTrigger to your update panel.
 <asp:UpdatePanel runat="server" >
   <triggers>
       <asp:AsyncPostBackTrigger ControlID="rbLoadPasteResume" EventName="SelectedIndexChanged" />
   </triggers>
       <ContentTemplate>
...
0
CamilliaAuthor Commented:
You guys are great. Thanks. Kamila.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.