|
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 NonStatic : System.Web.UI.Page,ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
RegisterCallBackReference();
}
/// <summary>
/// Sever Side Method to call
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private String ServerSideMethod(String args)
{
String arg = args;
if (arg == "Today")
return Convert.ToString(DateTime.Now.Date);
else if (arg == "Tomarrow")
return Convert.ToString(DateTime.Now.Date.AddDays(1));
return "";
}
#region "Call back Registration"
private void RegisterCallBackReference()
{
String callBack = Page.ClientScript.GetCallbackEventReference(this, "arg",
"CallbackOnSucceeded", "context", "CallbackOnFailed", true);
//String callBack = Page.ClientScript.GetCallbackEventReference(this, "arg",
// "", "context", "", true);
String clientFunction = "function CallServer(arg, context){ "
+ callBack + "; }";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"Call To Server", clientFunction, true);
}
#endregion
#region ICallbackEventHandler Members
String returnValue;
string ICallbackEventHandler.GetCallbackResult()
{
return returnValue;
}
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
returnValue = ServerSideMethod(eventArgument);
}
#endregion
}
|
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.