2016-09-21 69 views
0

我需要在做文件上傳後僅在發生圖像變化時發生事件。 我寫了下面的代碼。但它也觸發頁面加載。我不想要onload。我們如何實現它?僅在圖像變化時發生火災事件

$(document).ready(function() {   
     $('#Imgphoto1').on('load', function() { 
      alert(); 
      top.IsfieldChange("1"); 
     }); 
    }); 

<asp:Image ID="Imgphoto1" runat="server" AlternateText="No Photo Available" ImageUrl="../Designer/Images/DefaultEmployeeImage.jpg" 
            Width="153" Height="192" /> 

<asp:FileUpload ID="FileUpload12" runat="server" onpropertychange='return setPhoto(id);' onchange="validcheckFileExtension(this);" ToolTip="Allowed files('.jpeg', '.png', '.gif', '.jpg')" /> 
+1

共享所有相關代碼HTML CSS –

回答

0

試試這個..

$("document").ready(function(){ 

$("#upload").change(function() { 
    alert('changed!'); 
});}); 
+0

其不點火。 –

+0

哪個控件你正在使用? –

+0

asp.net圖像控制 –

0

只是用這樣的

$("#Imgphoto1").on('change',function() { 
 
       alert('img uploaded'); 
 
}); 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
<input type="file" id="Imgphoto1">

+0

這是我需要的東西。但爲什麼我的asp控制代碼不起作用? –