在asp.net vs05上工作。我知道如何顯示彈出窗口,在我的下面的語法中,當頁面加載時顯示彈出窗口。但是我想在服務器發生一些操作後顯示這個彈出窗口,我有一個按鈕,在這個按鈕事件下我想做一些工作在服務器端,然後我想顯示彈出式消息。這裏是我的完整語法,可以顯示彈出如何顯示服務器端的彈出消息
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!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>Untitled Page</title>
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type = "text/javascript">
$(document).ready(function() {
$("#message").fadeIn("slow");
$("#message a.close-notify").click(function() {
$("#message").fadeOut("slow");
return false;
});
});
</script>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id='message' style="display: none;">
<span>Hey, This is my Message.</span>
<a href="#" class="close-notify">X</a>
</div>
</form>
</body>
</html>
像上面的語法,我想要一些事件發生後,顯示從服務器端的彈出消息出現。這裏是我的aspx語法:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!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>Untitled Page</title>
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type = "text/javascript">
function computeCorrectValue(type parameter)
{
$(document).ready(function() {
$("#message").fadeIn("slow");
$("#message a.close-notify").click(function() {
$("#message").fadeOut("slow");
return false;
});
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>
C#語法:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//want to do some work then want
Button1.Attributes.Add("onclick", "javascript:computeCorrectValue(parameter)");
}
}
幫助我在服務器端發生一些事件後顯示彈出消息。popup必須看起來像我的第一個例子。我也可以顯示警報消息,但我不想顯示警報message.url http://stackoverflow.com/questions/659199/how-to-show-popup-message-like-in-stackoverflow
我想要相同的東西但要在服務器事件之後顯示。
+1不錯的解決方案:) – Somebody 2013-07-17 21:30:25