大侠看看,客户端确认后为false的情况还会执行服务端事件?
protected void Page_Load(object sender, EventArgs e)
{
btnAdd.Attributes.Add( "onclick ", "return CheckStr(); ");
}
js:
function CheckStr()
{
var o = document.getElementById( "FileUpload1 ").value;
if( o != null)
{
var strFileName = o.substr(o.lastIndexOf( "\\ ")+1);
if ((strFileName != null) || (strFileName != " "))
{
var url = "Admin_CheckFile.aspx?FileName= " + strFileName;
var xmlHttp = getXMLHTTP();
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status == 200)
{
var response = xmlHttp.responseText ;
if(response == "true ")
{
var flag = confirm( '已存在同名文件,是否覆盖? ');
if(flag)
{
alert(flag);
}
else
{
alert(flag);
document.form1.FileUpload1.focus();
}
return flag;
}
else
{
return false;
}