visual studio 2010中的模态弹出问题 [英] Issue with modal popup in visual studio 2010
本文介绍了visual studio 2010中的模态弹出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经完成了一个模态弹出窗口的代码,在VS2008中运行正常,但是当我在VS2010中做同样的代码时代码对我来说没有用,任何人都可以帮助我...
这是我的设计
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
推荐答案
find(' mpeModalPopUp')。add_shown(OnModalPopup);
if (!args.get_isPartialLoad()){
// 将我们的处理程序添加到文档的
// keydown事件
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){
// 如果按下的键是转义键,关闭对话框
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' 跨度>)隐藏();
}
如果(e&& e.keyCode == Sys.UI.Key.enter){
// 如果按下的键是回车键,则关闭对话框
alert(' Hello');
find('mpeModalPopUp').hide(); } if (e && e.keyCode == Sys.UI.Key.enter) { // if the key pressed is the enter key, dismiss the dialog alert('Hello');
这篇关于visual studio 2010中的模态弹出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文