var myarray;
window.onload = function(e)
{
myarray=new Array(document.forms["aspnetForm"].elements.length)
for (var j=0; j < document.forms["aspnetForm"].elements.length; j++)
myarray[j]=new Array(3)
for (var i = 0; i < document.forms["aspnetForm"].elements.length; i++)
{
var element = document.forms["aspnetForm"].elements[i];
var type = element.type;
myarray[i][0] = element;
myarray[i][1] = type;
if (type == "checkbox" || type == "radio")
{
if (element.checked)
myarray[i][2] = true;
else
myarray[i][2] = false;
}
else if (type == "password" || type == "text" ||
type == "textarea")
{
// if( type == "textarea")
// {
// var textDesc = this.editor_getHTML('ctl00_ContentPlaceHolder1_txtBodyMessage');
// if(textDesc != undefined || textDesc != null)
// myarray[i][2] = textDesc;
// else
// {
// if(element.value != "")
// myarray[i][2] = element.value;
// else
// myarray[i][2] = "";
// }
// }
// else
if(element.value != "")
myarray[i][2] = element.value;
else
myarray[i][2] = "";
}
else if (type == "select-one" || type == "select-multiple")
{
for (var j = 0; j < element.options.length; j++)
{
if (element.options[j].selected)
myarray[i][2] = j;
}
}
else
myarray[i][2] = "";
}
};
window.onbeforeunload = function(e)
{
e = e || window.event;
var hdnButton = document.getElementById("hdnClicked");
if( hdnButton != null && hdnButton != '' && hdnButton != undefined)
{
if(hdnButton.value != "save")
{
if (formIsDirty(document.forms["aspnetForm"]))
{
if (e)
e.returnValue = "You have unsaved data on this page and are attempting to navigate away without saving.";
}
}
}
else
{
if (formIsDirty(document.forms["aspnetForm"]))
{
if (e)
e.returnValue = "You have unsaved data on this page and are attempting to navigate away without saving.";
}
}
};
function formIsDirty(form)
{
for (var i = 0; i < form.elements.length; i++)
{
var element = form.elements[i];
var type = element.type;
if (type == "checkbox" || type == "radio")
{
if(myarray[i][2] != undefined)
{
if (element.checked != myarray[i][2])
return true;
}
}
else if (type == "password" || type == "text" ||
type == "textarea")
{
if( myarray[i][2] != undefined)
{
// if(type =="textarea")
// {
// if(element.value != "
")
// {
// if (element.value != myarray[i][2])
// return true;
// }
// }
// else
if (element.value != myarray[i][2])
return true;
}
}
else if (type == "select-one" || type == "select-multiple")
{
for (var j = 0; j < element.options.length; j++)
{
if (element.options[j].selected)
{
if( j != myarray[i][2])
return true;
}
}
}
}
return false;
}
function GetClicked()
{
var hdnButton = document.getElementById("hdnClicked");
if( hdnButton != null && hdnButton != '' && hdnButton != undefined)
hdnButton.value = "save";
}
*/script*
CS
ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
scriptManager.RegisterPostBackControl(btnCancel);
No comments:
Post a Comment