?
Solved

Validators inside Update Panel (VS2008)

Posted on 2010-01-11
18
Medium Priority
?
216 Views
Last Modified: 2013-11-26
I just noticed that if  I put validators inside update panels in Visual Studio 2008, they no longer function.  I must be missing something and I am sure this is an easy issue to deal with.  Can anyone give me any pointers here?

Thanks!
0
Comment
Question by:jglazer63
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 6
18 Comments
 
LVL 21

Expert Comment

by:silemone
ID: 26284386
this is a known error...and has always been the case


here a link that helps:

http://www.aspnettricks.com/archives/validators-inside-update-panel-doesnt-work-properly/
0
 
LVL 21

Expert Comment

by:silemone
ID: 26284424
just noticed you have vs2008..if you get vs2008 sp1, it's supposed to fix this...

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

Expert Comment

by:ajitha75
ID: 26284590
I tried this sample.. and it is working fine... Is there anything you have done? are both the controls and validators inside the updatepanel?

-Ajitha

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TextBox2" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>

Open in new window

0
Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

 

Author Comment

by:jglazer63
ID: 26284979
Well I updated to SP1 and i made no difference.  I am using a custom validator with a break point in the middle of it and its simply not firing.  I'll try putting the DLL in the BIN folder.
0
 
LVL 21

Expert Comment

by:silemone
ID: 26285004
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 26285025
It depends on how the page is setup. Can you post your code here?
0
 
LVL 21

Expert Comment

by:silemone
ID: 26285028
if not...if its working before you place into update panel

do you have:

set the EnableClientScript property of the validators to false
0
 

Author Comment

by:jglazer63
ID: 26286533
Code is as follows.  Visibility of the chosen control is set to True at runtime.
   <asp:TextBox ID="txtCustomName" runat="server" Visible="False"></asp:TextBox>
                                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                        ControlToValidate="txtCustomName" CssClass="fielderror" 
                                        ErrorMessage="Missing or Invalid Page Name" Display="Dynamic" 
                                        EnableClientScript="False"></asp:CustomValidator>
                                    <asp:CustomValidator
                                            ID="CustomValidator2" runat="server" 
                                        ErrorMessage="Page Already Exists" ControlToValidate="txtCustomName" 
                                        CssClass="fielderror" Display="Dynamic" EnableClientScript="False"></asp:CustomValidator>

Open in new window

0
 
LVL 14

Expert Comment

by:ajitha75
ID: 26286902
How are you mapping the Validate event (OnServerValidate) with the handler? I dont see that in the html definition.
0
 
LVL 21

Expert Comment

by:silemone
ID: 26287093
he's using: ControlToValidate ajitha


could you leave visibility as True and try it?  see if it works when the textbox is visible from the onset...
0
 

Author Comment

by:jglazer63
ID: 26288121
I did try visiility to true with no difference.
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 26288216
ControlToValidate is fine. But since you are using a CustomValidator, to validate in server side, I suppose you have an handler, which should be fired during postback. Do you have that? how is that attached to the Control event?
0
 

Author Comment

by:jglazer63
ID: 26288224
Yea, its set in the events.
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 26288237
ok. can you share your .cs code then?
0
 

Author Comment

by:jglazer63
ID: 26288416
I did confirm that bysimply removing the updatepanel, it works perfecly fine.  If its inside, no go.  Does that help?  not sure what the .CS code is.
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 26290070
.cs is code behind code... like for ex. where are you setting the textbox visibility to true?

-Ajitha
0
 
LVL 21

Accepted Solution

by:
silemone earned 2000 total points
ID: 26293568
I think the problem is the visiblity at preinit...its not seen...therefore not attached to the validator...that's why it may be better to have everything visible at the beginning and set up through the control...make any other changes such as visibility in page load...
0
 

Author Closing Comment

by:jglazer63
ID: 31675532
That worked.  Thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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