Click here to Skip to main content
15,881,803 members
Articles / Programming Languages / Java

Ajaxion - Standalone AJAX - Part 2 of 2 - C# and Java Example

Rate me:
Please Sign up or sign in to vote.
4.97/5 (34 votes)
22 Jan 2013CPOL5 min read 55.1K   1.4K   42  
An article about how to keep AJAX simple as it is and get the most out of it.
var IE = document.all && document.getElementById;

function ElemId(event)
{
	var elem;
	if (IE)
		elem = window.event.srcElement;
	else
		elem = event.target;
	return elem.attributes["id"].value;
}

function DragDrop()
{
	// Members
	var sourceId = "";
	var targetId = "";
	
	// Expose Methods
	this.Initialize = Initialize;
	this.SetSourceId = SetSourceId;
	this.SetTargetId = SetTargetId;
	this.Drop = Drop;
	this.DefaultActionIE = DefaultActionIE;
	this.GetSourceId = GetSourceId;
	this.GetTargetId = GetTargetId;

	// Exposed Methods

	function Initialize()
	{
		this.sourceId = "";
		this.targetId = "";	
	}

	function GetSourceId()
	{
		return this.sourceId;
	}

	function SetSourceId(elemId)
	{
		this.sourceId = elemId;
		DefaultActionIE(false);
	}

	function SetTargetId(elemId)
	{
		this.targetId = elemId;
		DefaultActionIE(false);
	}
	
	function GetTargetId()
	{
		return this.targetId;
	}

	function Drop(e)
	{
		this.targetId = ElemId(e);
		var sourceElem = window.document.getElementById(this.sourceId);
		var targetElem = window.document.getElementById(this.targetId);
		if (sourceElem != null && targetElem != null)
			ajaxion.postUrl("AjaxCallbackWs.asmx/GetImageUrl", imageUrlEvent, GetImageCallback);
		Initialize();
	}

	function DefaultActionIE(enabled)
	{
		if (IE)
			window.event.returnValue = enabled;
	}
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
New Zealand New Zealand
Coder

Comments and Discussions