?
Solved

Want page to post back and display error msgs on page

Posted on 2010-03-26
14
Medium Priority
?
344 Views
Last Modified: 2012-05-09
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

0
Comment
Question by:Camillia
  • 8
  • 3
  • 2
  • +1
14 Comments
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 800 total points
ID: 28690806
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
 
LVL 27

Assisted Solution

by:Shaun Kline
Shaun Kline earned 800 total points
ID: 28691043
Try using the ValidatorSummary control. It will display the ErrorMessage property for any validator that fails.
0
 
LVL 7

Author Comment

by:Camillia
ID: 28691701
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 7

Author Comment

by:Camillia
ID: 28691967
I had AutoPostBack for the Telerik Calendar, i dont think i need that either...
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 28692257
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
 
LVL 7

Author Comment

by:Camillia
ID: 28692761
>>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
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 28692946
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
 
LVL 7

Author Comment

by:Camillia
ID: 28693174
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
 
LVL 7

Author Comment

by:Camillia
ID: 28693239
ok, just saw your msg above about trigges... Let me try this and will post back
0
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 400 total points
ID: 28693495
*** 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
 
LVL 7

Author Comment

by:Camillia
ID: 28693971
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
 
LVL 7

Author Comment

by:Camillia
ID: 28706206
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
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 28707129
Try adding an AsyncPostBackTrigger to your update panel.
 <asp:UpdatePanel runat="server" >
   <triggers>
       <asp:AsyncPostBackTrigger ControlID="rbLoadPasteResume" EventName="SelectedIndexChanged" />
   </triggers>
       <ContentTemplate>
...
0
 
LVL 7

Author Closing Comment

by:Camillia
ID: 31707548
You guys are great. Thanks. Kamila.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question