Click here to Skip to main content
15,886,584 members

modalpopup extender not showing

harrypsd1789 asked:

Open original thread
Im trying to follow a article from code project regarding of placing a required field validator in a modal popup:In my master page i have the following asp.net code:
XML
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <link rel="icon" type="image/ico" href="favicon.ico"/>
    <link rel="shortcut icon" href="favicon.ico"/>
     <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
        </head>
<body>

    <form runat="server">
    <asp:ScriptManager ID="scriptMgr" runat="server">
                    </asp:ScriptManager>

    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    <asp:Image ID="Image1" runat="server" BorderStyle="Double" Height="49px"
                        ImageAlign="Left" ImageUrl="~/FNU_logo.jpg" style="margin-left: 0px; margin-top: 5px;"
                        Width="206px" />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RECORDS MANAGEMENT
                    SYSTEM</h1>
</div>
            <div class="clear hideSkiplink">
            <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
                    EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal"
                    BackColor="#F7F6F3" DynamicHorizontalOffset="2" Font-Names="Verdana"
                    Font-Size="0.8em" ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                    <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                    <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                    <DynamicMenuStyle BackColor="#F7F6F3" />
                    <DynamicSelectedStyle BackColor="#5D7B9D" />
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default2.aspx" Text="File Records"/>
                        <asp:MenuItem NavigateUrl="~/ViewRecords.aspx" Text="View Recods"/>
                    </Items>
                     <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                    <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                    <StaticSelectedStyle BackColor="#5D7B9D" />
                     </asp:Menu>
                      <div class="main">


            <asp:ContentPlaceHolder ID="MainContent" runat="server">
                <div style="width: 1066px; height: 463px; margin-left: 0px">
             </div>
         </asp:ContentPlaceHolder>





                    <br />
                    <br />
                    <br />


                &nbsp;<br />
                    <br />

&nbsp;

                    <asp:UpdatePanel ID="update" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Panel ID="errorsPanel" runat="server" Style="display: none;  border-style:solid;
                    border-width: thin; border-color: #FFDBCA" Width="175px" BackColor="White">
                             <div style="text-align: left">

                                <asp:ValidationSummary ID="valSummary" runat="server" DisplayMode="BulletList" ShowSummary="true"
                            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="HellowWorldPopup">
                            </asp:ModalPopupExtender>
                        </ContentTemplate>
                    </asp:UpdatePanel>

                </div>

            </div>

            </div>
        </div>





    <div class="footer">

        CopyRight@Fiji National University</div>
    </form>
</body>
</html>


then in my master code behind i have:

C#
public partial class SiteMaster : System.Web.UI.MasterPage
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!HttpContext.Current.User.Identity.IsAuthenticated )

        {
            NavigationMenu.Items.Clear();
        }
    }

   public String ValidationGroup
    {
        set
        { valSummary.ValidationGroup = value; }
    }

    public bool CheckErrors()
    {
        Page.Validate(valSummary.ValidationGroup);
        if (!Page.IsValid)
        {
                update.Update();
                modalPopupEx.Show();
            return false;
        }
        return true;
    }

}

Then from another web form i trying to validate a textbox like this:

C#
protected SiteMaster PageMaster
   {
       get
       {
           return this.Master as SiteMaster;
           //return this.Site as SiteMaster;
       }
   }
   protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
   {
       //SiteMaster master = (SiteMaster)this.Master;
       if (PageMaster.CheckErrors())
       {


}

The problem is that the validations only occurs at the server side and no popup appears at the client end...Where do im doing something wrong and how can i show up the popup

Thanks
Tags: C# (C# 3.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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