In one of our project, we use NeatUpload to upload file to servers. There is an issue that when you place a NeatUpload control on the page, and you have a control with “return false” in event onclick, the “return false” won’t stop the execution of the control. This issue happens in Internet Explorer.
For example, I have a LinkButton control on the page named lbDelete, and I want to user confirm before submit. Usually I write like this:
lbDelete.Attributes.Add("onclick"
, "return confirm('Are you sure to delete this picture from the gift picture library ?')");
But, if there’s a NeatUpload control on the page, whatever the choice the user selects, the “Delete” action will always be executed.
So I did a little trick on the link button’s onclick event:
if(document.all)
{
if(!confirm('Are you sure to delete this picture from the gift picture library ?'))
{
if(this.href!='#aImageGallery')
{
//save the original href value, and point to an anchor
this.setAttribute('href1',this.href);
this.href='#aImageGallery';
}
return false;
}
else
{
if(this.getAttribute('href1'))
{
this.href=this.getAttribute('href1');
}
}
}
else
{
return confirm('Are you sure to delete this picture from the gift picture library ?');
}
And the compressed one when you want to add the onclick in codebehind:
lbDelete.Attributes.Add("onclick", "if(document.all){if(!confirm('Are you sure to delete this picture from the gift picture library ?')){ if(this.href!='#aImageGallery'){ this.setAttribute('href1',this.href); this.href='#aImageGallery';} return false;}else{ if(this.getAttribute('href1')){this.href=this.getAttribute('href1'); }}}else{ return confirm( 'Are you sure to delete this picture from the gift picture library ?');}");
Hope it helps someone having the same problem in NeatUpload control. 🙂