﻿function UpdateFileList_On_Close(elementId, dropdownId)
{
	//alert(elementId);
	ASP.FileDownload.ListFiles(elementId, UpdateFileList_callback, dropdownId);
	
}

function UpdateFileList_callback(result)
{
	//alert (result.context);
	var objDropDown = document.getElementById(result.context);
	//alert (result.value);
	
	if (objDropDown != null)
	{
		var fileList = new Array();
		fileList = result.value;
		var i;
		if (objDropDown.length > 0)
		{
			for (i = objDropDown.length-1; i >= 0;  i--)
			{
				objDropDown.remove(i);
			}
		}
		
		var opt = document.createElement('option');
		opt.value = "0";
		opt.text = "Please Select ...";
		objDropDown.add(opt, 0);
		
		for (i=0; i<= fileList.length-1; i++)
		{
			var opt1 = document.createElement('option');
			opt1.value = fileList[i].fileId;
			opt1.text = fileList[i].fileName;
			objDropDown.add(opt1, i+1);
		
		}
	}
}
/// Control function
function Request_Download(dropdownControlId)
{
	var ddl = document.getElementById(dropdownControlId);
	
	if (ddl.selectedIndex == -1 || ddl.selectedIndex == 0 )
	{
		alert("Please select a file!");
		return false;
	}
	else
	{
		return true;
	}

}