UpdatePanel doesn't refresh in presence of RequiredFieldValidator

Last post 06-16-2009 8:56 AM by dovr. 4 replies.

Sort Posts:

  • UpdatePanel doesn't refresh in presence of RequiredFieldValidator

    06-15-2009, 4:14 PM
    • Member
      1 point Member
    • dovr
    • Member since 09-08-2008, 12:49 PM
    • Posts 8
    Hello, all. I've been having trouble with an UpdatePanel not refreshing and I've isolated the problem as the presence of a RequiredFieldValidator on the same page. I know that a RequiredFieldValidator cannot be nested inside an UpdatePanel, but I believed that they could co-exist on the same page otherwise. Is that incorrect?

    Here's the code. Note if you simply remove the RFV control, it works as expected. Any help or insight would be greatly appreciated!

    <%@ Page Language="VB" AutoEventWireup="false" Codefile="testpage.aspx.vb" Inherits="testpage" %> <html>
    <head></head>
    <body><form runat="server" ID="form1">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <asp:TextBox id="Text1" runat="server"></asp:TextBox>
        <asp:requiredfieldvalidator id="rfv1" runat="server" ControlToValidate="Text1" Text=""/>
        <asp:Button ID="Button1" Text="Refresh Panel" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
             <Triggers>
               <asp:AsyncPostBackTrigger ControlID="Button1" />
             </Triggers>
             <ContentTemplate>
             <%=DateTime.Now.ToString() %>
             </ContentTemplate>
        </asp:UpdatePanel>
    </form></body>
    </html>

  • Re: UpdatePanel doesn't refresh in presence of RequiredFieldValidator

    06-15-2009, 5:53 PM
    • Contributor
      2,141 point Contributor
    • rrmacman
    • Member since 06-10-2008, 7:04 PM
    • Cleveland, OH
    • Posts 453

     what do you mean a requieredfieldvalidator cannot be nested inside an update panel? i do it all the time with no troubles.

  • Re: UpdatePanel doesn't refresh in presence of RequiredFieldValidator

    06-15-2009, 6:01 PM
    • Member
      1 point Member
    • dovr
    • Member since 09-08-2008, 12:49 PM
    • Posts 8
    rrmacman:

     what do you mean a requieredfieldvalidator cannot be nested inside an update panel? i do it all the time with no troubles.

    As I was trying to solve my problem, I came across a wide variety of information and forum posts about various troubles caused by nesting requiredfieldvalidator inside an updatepanel.

    For example, http://www.4guysfromrolla.com/demos/printPage.aspx?path=/articles/102407-1.aspx, which mentions it fairly explicitly at the bottom.

    In any case, I didn't try it, as my problem is more fundamental (i.e. it doesn't appear to work for me anywhere on the page).
  • Re: UpdatePanel doesn't refresh in presence of RequiredFieldValidator

    06-15-2009, 11:47 PM
    • Star
      8,587 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 11:37 AM
    • Bangalore
    • Posts 1,261

    Hi 

    Yes , there has been some issue on the usage of validation control along with updatepanel . You can get to know more(including solution) on this from following link :-

    http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

    http://trailfire.com/gotchi/trailview/33378

    http://stackoverflow.com/questions/124249/do-standard-asp-net-validators-work-with-ajax-and-update-panel

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
  • Re: UpdatePanel doesn't refresh in presence of RequiredFieldValidator

    06-16-2009, 8:56 AM
    Answer
    • Member
      1 point Member
    • dovr
    • Member since 09-08-2008, 12:49 PM
    • Posts 8
    Pawan_Mishra:

    Hi 

    Yes , there has been some issue on the usage of validation control along with updatepanel . You can get to know more(including solution) on this from following link :-

    http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

    http://trailfire.com/gotchi/trailview/33378

    http://stackoverflow.com/questions/124249/do-standard-asp-net-validators-work-with-ajax-and-update-panel


    Thanks, but none of those seem to help. All of the articles seem to be about the problem that the validators won't update when they're inside an updatepanel. My problem is the reverse - the updatepanel won't refresh (and the validator is outside). I've also tried putting the validator and textbox inside the updatepanel, as well as inside a separate updatepanel. Also tried setting UpdateMode to Always just to see if it made a difference. Nothing worked.

    Upon further review, though, I tried this example (just to see if I could get anything to work): http://msdn.microsoft.com/en-us/library/bb398929.aspx. It worked. After slowly stripping it down to look like the original code, I discovered that my original code works fine if I put something valid in the textbox.

    So, just setting CausesValidation="false" on the button made everything work. Thanks!
Page 1 of 1 (5 items)