JavaScript 弹出模式对话框
用JavaScript 弹出模式对话框 ,其实很简单,只需要调用showModalDialog这个函数就可以实现下面是一段ASP.NET页面完整代码,它作为模式对话框的父窗口,其实现的功能是点击按钮后将TextBoxTestId和
HiddenUserId 两个控件的值通过查询字符串传递给模式对话框。这里要注意的是showModalDialog函数的第二个
参数,通过这个参数可以把父窗口的对象带给模式对话框,模式对话框可以通过window.dialogArguments这个属性获取到父窗口带入的参数,这里填写的参数是父窗口的window 对象。
<div style="padding: 4px 5.4pt; width: 95%;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif<html xmlns="http://www.w3.org/1999/xhtml" >
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif<head runat="server">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <title>无标题页</title>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif<script language="javascript" type="text/javascript">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif function btn_Ok_onclick()
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif {
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var testId = document.getElementById("TextBoxTestId").value;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var userId = document.getElementById("HiddenUserId").value;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif showModalDialog("OpenMessage.aspx?UserId="+userId
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif + "&TestId=" + testId ,window,
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif 'dialogwidth:450px;dialogheight:480px;help:0;center:yes;resizable:0;status:0;scroll:yes');
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return(false);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif </script>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif</head>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif<body>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <form id="form1" runat="server">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <div>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default.aspx">HomePage</asp:HyperLink><br />
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/Default.aspx" Target="_blank">HomePageNewWindow</asp:HyperLink><br />
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <asp:TextBox ID="TextBoxTestId" runat="server"></asp:TextBox>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif &nbsp;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <asp:Button ID="ButtonTestId" runat="server" Text="Button" OnClientClick="btn_Ok_onclick()" />
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <asp:HiddenField ID="HiddenUserId" runat="server" />
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif </div>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif </form>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif</body>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif</html>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
页:
[1]