ModalPopupExtender and validation problems

南笙酒味 提交于 2019-12-04 00:27:18

This is an issue with using both ValidationSummary and ModalPopup.

see here: http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=12835

The problem is that there is a missing ";" between the two injected scripts.

Their solution is to create/use a custom server control that inherits from ValidationSummary, that injects a ";" into the page startup script to fix the bug:

[ToolboxData("")]
public class AjaxValidationSummary : ValidationSummary
{
  protected override void OnPreRender(EventArgs e)
  {
    base.OnPreRender(e);
    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), this.ClientID, ";", true);
  }
}

Try setting your ValidationSummary "Enabled" property to false on this event : "btnPush_Click" ; and then setting it back to enabled = "true" on this events : "btnOK_Click" ,"btnCancel_Click".

I think this will work if you do not have the validation summary inside the Panel that you want to pop up.But it is not a solution if you need the validation summary inside the pop up panel,...witch is my case :(.

Best Regards.

I tried all the available answer online but didn't worked any. Then i tried to move my modal popup extender at very end of the HTML and it works fine for me. Me and my users are Happy :) I am not using FROM tag I am using Content place holder just like below:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
 <table id="tblMessage" runat="server" width="100%" >
    <tr align="center">
        <td align="center">

main content and

<asp:Panel ID="pnlSelectClient" Style="display: none" CssClass="box" runat="server">

  <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
    <asp:UpdatePanel ID="upnlSelectClient" runat="server">
        <ContentTemplate>
            <asp:Button ID="btnOK" runat="server" UseSubmitBehavior="true" Text="OK" CausesValidation="false" OnClick="btnOK_Click" />
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </asp:Panel>

If you notice i have validation summary inside the panel because i want error message inside the pop up(i have some additional control in pop up too). and

Some more HTML tag here as i have so many other things to do in one page. right before closing tag of TABLE

<ajaxToolkit:ModalPopupExtender ID="mpeSelectClient" runat="server" 
    TargetControlID="popupDummy"
    PopupControlID="pnlSelectClient" 
    OkControlID="popupDummy"
    BackgroundCssClass="modalBackground" 
    CancelControlID="btnCancel" 
    DropShadow="true"  />

</table>

Done.it's working. Hope that works for other too.

Are you using validation groups anywhere on the page? I've had problems with control events not firing when they are not part of a validation group and other controls on the page are part of a validation group.

I'd try changing this:

<input id="popupDummy" runat="server" style="display:none" />

to something like this:

<asp:Button id="popupDummy" runat="server" CausesValidation="false" Visible="false" />

I bet the untyped input is requiring validation.

i had the same issue, adding ValidationGroup to the validation controls did the trick!

One other thing to try, if you don't need Client Script you can disable it in the markup. Doing that fixed our problem.

EnableClientScript="false"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!