I have done a code for modal pop-up which works fine in VS2008, but when i did the same in VS2010 the code didn't work for me can any one help me...
This is my design
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function pageLoad(sender, args) { $find('mpeModalPopUp').add_shown(OnModalPopup); if (!args.get_isPartialLoad()) { // add our handler to the document's // keydown event $addHandler(document, "keydown", onKeyDown()); } function onKeyDown(e) { if (e && e.keyCode == Sys.UI.Key.esc) { // if the key pressed is the escape key, dismiss the dialog $find('mpeModalPopUp').hide(); } if (e && e.keyCode == Sys.UI.Key.enter) { // if the key pressed is the enter key, dismiss the dialog alert('Hello'); $find('mpeModalPopUp').hide(); } } function OnModalPopup(e) { $get('mpeModalPopUp').focus(); } } </script> <script type="text/javascript"> function popup1() { //alert('Hello'); $find('mpeModalPopUp').hide(); } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="Script1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="upModalPopUp" runat="server"> <ContentTemplate> <asp:Button ID="btnModalPopUp" runat="server" Style="display: none" /> <asp:ModalPopupExtender ID="mpeModalPopUp" runat="server" TargetControlID="btnModalPopUp" PopupControlID="pnlNoPayroll" CancelControlID="ImgOk" BackgroundCssClass="modalBackground"> </asp:ModalPopupExtender> <asp:Panel ID="pnlNoPayroll" runat="server" BackColor="White" Height="100px" Width="400px" Style="display: none"> <table width="100%" style="border: Solid 2px #999; width: 100%; height: 100%" cellpadding="0" cellspacing="0"> <tr style="background-image: removed(images/title.gif)"> <td style="height: 10%; color: Black; padding: 2px; font-size: larger; font-family: Calibri" align="center"> Information </td> <td style="color: White; font-weight: bold; padding: 3px; font-size: larger" align="Right"> <a href="java<!-- no -->script:void(0)" önclick="popup1()"> <img src="images/x.png" style="border: 0px" align="right" /></a> </td> </tr> <tr> <td align="center" style="padding-removed 5px; font-family: Calibri"> <asp:Label ID="lblPopUp" runat="server" /> </td> </tr> <tr> <td align="center" style="padding-removed 15px"> <asp:ImageButton ID="ImgOk" CssClass="Selected" runat="server" ImageUrl="images/button_ok.gif" /> </td> </tr> </table> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <div> <asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="personal" Style="left: 459px; position: absolute; top: 171px" OnClick="Button1_Click" /> </div> </form> </body> </html>
My code in button click
protected void Button1_Click(object sender, EventArgs e) { lblPopUp.Text = "<img src='Popup(Images)/information.png' /> Access Denied,Contact Administrator"; mpeModalPopUp.Show(); }
I am unable to hide the pop-up on hitting enter or escape can any one tell where I went wrong. Also what should I do when I am working with master pages with the same code