87,910
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
function test()
{
alert("调用");
}
$(function(){
$('#dialog').dialog({
autoOpen: true,//如果设置为true,则默认页面加载完毕后,就自动弹出对话框;相反则处理hidden状态。
bgiframe: true, //解决ie6中遮罩层盖不住select的问题
width: 600,
modal:true,//这个就是遮罩效果
buttons: {
"Ok": function() {
test();//在这里调用函数
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$('#btn').click(function(){
$('#dialog').dialog('open');
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="demo">
<div>
<input type="button" id="btn" value="点我啊" />
<div>
<div id="dialog" title="嘿嘿" style="">
<p>
你个废物</p>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
$(function(){
$('#dialog').dialog({
autoOpen: false,//如果设置为true,则默认页面加载完毕后,就自动弹出对话框;相反则处理hidden状态。
bgiframe: true, //解决ie6中遮罩层盖不住select的问题
width: 600,
modal:true,//这个就是遮罩效果
buttons: {
"Ok": function() {
$.ajax({
type: "post",
contentType: "application/json;utf-8",
url: "default2.aspx/GetDate",
data: "{str:\"" + $("#TextBox2").val() + "\"}",
success: function(msg) {
alert(msg.d.SuccessMsg);
$("#TextBox1").empty();
$("#TextBox1").val(msg.d.SuccessMsg);
},
error:function(msg){
alert( "Error: " + msg );
}
});
$(this).dialog("close");},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$('#loading').dialog({
autoOpen: false,//如果设置为true,则默认页面加载完毕后,就自动弹出对话框;相反则处理hidden状态。
bgiframe: true, //解决ie6中遮罩层盖不住select的问题
width: 300,
modal:true,//这个就是遮罩效果
resizable:false,
dialogClass: 'alert'
});
$('#btn').click(function(){
$('#dialog').dialog('open');
return false;
});
$("#btnAjax").click(function()
{
$.ajax({
type: "post",
contentType: "application/json;utf-8",
url: "default2.aspx/GetDate",
data: "{str:\"" + $("#TextBox1").val() + "\"}",
success: function(msg) {
alert(msg.d.SuccessMsg);
},
error:function(msg){
alert( "Error: " + msg );
}
});
});
//对与Ajax的监控,本身是全局性的dialog( 'disable' )
$(document).ready(function() {
$('#loading').ajaxStart(function(){
$(this).dialog('open');
}).ajaxStop(function() {
$(this).dialog('close');
});
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="demo">
<div>
<input type="button" id="btn" value="点我啊" />
<div>
<div id="dialog" title="嘿嘿">
<p>
这里是内容!</p> <asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>
</div>
</div>
</div>
</div>
<input type="button" value="ajax获取" id="btnAjax" />
<span id="dt"></span>
<div id="tdiv">
</div>
<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
<div id="loading" style="border: 1px solid #808080; width: 300px; height: 50px; display: none;">
<p>
正在加载~</p>
</div>
</form>
[WebMethod]
public static CallbackMessage GetDate(string str)
{
CallbackMessage msg = new CallbackMessage();
msg.IsSuccess = true;
msg.SuccessMsg = "成功!" + str;
return msg;
}