[HTML]
<head runat="server">
<script type="text/javascript">
function btnCall(c) {
CallTheServer(c, "");
}
function CallTheServer(arg, context) {
WebForm_DoCallback('__Page', arg, ReceiveServerData, context, null, false)
}
function ReceiveServerData(result) {
document.getElementById('ID').innerHTML = result; //取值
}
</script>
</head>
<body>
<form id="form1" runat="server">
<!--呼叫function-->
<a href='#' onclick='btnCall(<%#Eval("ID") %>);return false;' >
</form>
</body>
[.CS]
public partial class PageName: System.Web.UI.Page, ICallbackEventHandler
{
private string callbackResult = string.Empty; //回傳值,只能為string
//ICallbackEventHandler 成員
public string GetCallbackResult()
{
return callbackResult; //傳值
}
public void RaiseCallbackEvent(string eventArgument) //eventArgument=c(前台傳值)
{
callbackResult ="data";
}
}
<head runat="server">
<script type="text/javascript">
function btnCall(c) {
CallTheServer(c, "");
}
function CallTheServer(arg, context) {
WebForm_DoCallback('__Page', arg, ReceiveServerData, context, null, false)
}
function ReceiveServerData(result) {
document.getElementById('ID').innerHTML = result; //取值
}
</script>
</head>
<body>
<form id="form1" runat="server">
<!--呼叫function-->
<a href='#' onclick='btnCall(<%#Eval("ID") %>);return false;' >
</form>
</body>
[.CS]
public partial class PageName: System.Web.UI.Page, ICallbackEventHandler
{
private string callbackResult = string.Empty; //回傳值,只能為string
//ICallbackEventHandler 成員
public string GetCallbackResult()
{
return callbackResult; //傳值
}
public void RaiseCallbackEvent(string eventArgument) //eventArgument=c(前台傳值)
{
callbackResult ="data";
}
}
留言
張貼留言