|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NonStatic.aspx.cs" Inherits="NonStatic" %>
<!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>Non Static Web Method Call</title>
</head>
<body>
<form id="form1" runat="server">
<input id="btnToday" onclick="GetDate(this)" type="button" value="Server Date" />
<input id="btnTomarrow" onclick="GetDate(this)" type="button" value="Tomarrow Date" />
<div id="divDisplayDate" style="padding-top: 50px;">
</div>
<div>
Date: <span id="DisplayDate"></span> Day: <span id="DisplayDay"></span>
</div>
</form>
<script type="text/javascript">
function GetDate(btn)
{
var context=new Object();
switch(btn.id){
case 'btnToday':
context.flag='Today';
break;
case 'btnTomarrow':
context.flag='Tomarrow';
break;
}
//Registered from code behind as:function CallServer(arg, context)
CallServer(context.flag,context);
}
function CallbackOnSucceeded(result,context)
{
switch(context.flag)
{
case 'Today':
DisplayDate.innerHTML = result;
break;
case 'Tomarrow':
DisplayDay.innerHTML = result;
break;
}
}
function CallbackOnFailed(result,context)
{
divDisplay.innerHTML =result;
}
</script>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.