<body>
<form id="frmLogin" runat="server">
<asp:Button ID="btnClick" OnClientClick="openConfirmDialog();" OnClick="PopulateLabel" runat="server"/>
<div id="divDialog"></div>
<asp:Label ID="lblText" runat="server"></asp:Label>
</form>
</body>
JS
<script type="text/javascript">
$(document).ready(function() {
$("#divDialog").dialog({autoOpen: false,
buttons: { "Ok": function()
{
$(this).dialog("close");
},
"Cancel": function()
{
$(this).dialog("close");
}
}
});
});
function openConfirmDialog()
{
$("#divDialog").dialog("open");
}
C#
protected void Page_Load(object sender, EventArgs e)
{
lblText.Text = "";
}
protected void PopulateLabel(object sender, EventArgs e)
{
lblText.Text = "Hello";
}
這段代碼打開我確定和取消對話框按鈕,但它不會等待用戶ac並立即張貼頁面,標籤被填充。我需要根據用戶活動調用c#函數。如果用戶點擊「確定」標籤應該填充,如果用戶點擊「取消」,它不應該調用c#函數。我如何實現這一目標?
__doPostBack(「btnClick」,「」);沒有調用我的c#函數 – 2010-12-08 07:53:44