Click here to Skip to main content
13,189,884 members (61,205 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » Howto » Downloads


123 bookmarked
Posted 2 Aug 2004

Implement Script Callback Framework in ASP.NET 1.x

, 2 Aug 2004
It allows calls to server events from client script code without causing the page to post back and refresh.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace ScriptCallbackFramework
	/// <summary>
	/// Implement the in IClientCallbackEventHandler Page Control
	/// </summary>
	public class index : PageTemplate, IClientCallbackEventHandler
		#region Member Vars
		protected System.Web.UI.HtmlControls.HtmlInputButton IncreaseButton;
		protected System.Web.UI.HtmlControls.HtmlInputText txtValue;
		protected ScriptCallbackFramework.AgeCalculator AgeCalculator1;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
			this.Load += new System.EventHandler(this.Page_Load);

		#region Page_Load
		private void Page_Load(object sender, System.EventArgs e)
			if (!Page.IsPostBack)
				//	Callback synchronously
				IncreaseButton.Attributes["onclick"] = GetSyncCallbackEventReference
						String.Format("document.getElementById('{0}').value", txtValue.UniqueID),
						String.Format("document.getElementById('{0}')", txtValue.UniqueID),

		#region IClientCallbackEventHandler Members

		public string RaiseClientCallbackEvent(string eventArgument)
			if (eventArgument == null || eventArgument == String.Empty)
				return "1";
			return Convert.ToString(Convert.ToInt32(eventArgument) + 1);

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Elvin Cheng
Singapore Singapore
Elvin Cheng is currently living in Woodlands, Singapore. He has been developing applications with the .NET Framework, using C# and ASP.NET since October 2002. Elvin specializes in building Real-time monitoring and tracking information system for Semi-conductor manufacturing industry. During his spare time, he enjoys reading books, watching movie and gym.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171016.2 | Last Updated 3 Aug 2004
Article Copyright 2004 by Elvin Cheng
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid