Monday, March 26, 2012

Modal popup is not modal

Hi!

My modal popup doesnt seem to be modal: see the code below. Everything works fine, but when popup appears link behind still can be clicked... What's missing?

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxToolkit" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Button ID="btnShowPopup" Text="ShowPopup" runat="server" /> <a href="http://www.google.com">Some link</a> <br /> <div id="divPopup" runat="server" style="background-color:Silver; width:500px; height:300px;"> <div id="divHeader" runat="server" style="background-color:Lime"> Header </div> <br /> Some popup content <br /> <asp:Button runat="server" ID="btnOK" Text="OK" /> </div> </div> <AjaxToolkit:ModalPopupExtender runat="server" ID="extPopup" TargetControlID="btnShowPopup" PopupControlID="divPopup" OkControlID="btnOK" PopupDragHandleControlID="divHeader" /> </form></body></html>

PawelRoman:

My modal popup doesnt seem to be modal: see the code below. Everything works fine, but when popup appears link behind still can be clicked... What's missing?

So your issue isn't with anything pertaining to the ModalPopupExtender, but rather with your CSS. Basically, you don't have any CSS. You need to set theBackgroundCssClass attribute on the ModalPopupExtender. Then, you'll need to add that CssClass using inline CSS or using a stylesheet. The CssClass must contain a background definition (background-color or background-image).

No comments:

Post a Comment