Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have placed a requiredfieldValidator for a textbox validation and ModularPopUpextender to show up the message.The validation does occurs but only on the server site and no message(popup)occurs at the client site.The Asp code is:
XML
<asp:UpdatePanel ID="update" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
                    <asp:Panel ID="errorsPanel" runat="server" Height="41px"
                        style="margin-left: 54px; margin-top: 144px" Width="812px" BackColor="White">
                        <div style="text-align: left">
                        <asp:ValidationSummary ID="valSummary" runat="server" ShowSummary="true" DisplayMode="BulletList"
        ValidationGroup="valGroup" />

<div style="text-align: right">
       <asp:Button ID="okBtn" runat="server" Text="Ok" /></div>

                        </div>
                    </asp:Panel>
                     <asp:Label ID="invisibleTarget" runat="server" Style="display: none" />
                    <asp:ModalPopupExtender ID="modalPopupEx" runat="server" PopupControlID="errorsPanel"
                      TargetControlID="invisibleTarget" CancelControlID="okBtn" BackgroundCssClass="modalBackground" DropShadow="true">
                    </asp:ModalPopupExtender>
                    </ContentTemplate>
</asp:UpdatePanel>


The method in the master page is:
C#
public partial class SiteMaster : System.Web.UI.MasterPage 
{
    
    public bool CheckErrors()
    {
        //Page x=new System.Web.UI.Page();
        ValidationSummary sum= new ValidationSummary();
        Page.Validate(sum.ValidationGroup);//error is in this line
        if (!Page.IsValid)
        {
           
            //this.EnsureChildControls();
            UpdatePanel update = new UpdatePanel();
            update.ID = "update";
            update.UpdateMode = UpdatePanelUpdateMode.Conditional;
            update.Update();
            modalPopupEx = new AjaxControlToolkit.ModalPopupExtender();
           
            modalPopupEx.Show();
            return false;
        }
        return true;
    }
}


The the click event in the web form is:
C#
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        SiteMaster master = (SiteMaster)this.Master;
        if (master.CheckErrors())
        {
            GridView2.Visible = false;
            gvsearch.Visible = true;

            string search = txtsearch.Text.ToString();
            gvsearch.DataSource = DataBase2.myProcedureName(search);
            gvsearch.DataBind();
        }
    }


I have also set the valiadtion group of the controls:(Textbox,RequireFieldValidator and Button)

Thanks
Posted
Updated 2-Sep-12 19:23pm
v2
Comments
AmitGajjar 3-Sep-12 2:11am    
in your aspx page there is no ImageButton2_Click event defined. where is ImageButton2 button aspx code?

1 solution

hi @Member 9291223377


due to updatepanel your modalpopup not display,
i think you should remove updatepanel,,,

try it,,,,

otherwise you just set updatepanel
C#
Childrenastrigger="true"


hope this will help you...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900