0

請參考此代碼,它是我使用mvc開發的web應用程序的局部視圖。如何處理javascript中的局部視圖元素

@model PortalModels.WholeSaleModelUser 
    @using (Html.BeginForm("uploadFile", "WholeSaleTrade", FormMethod.Post, new { enctype = "multipart/form-data" })) 
    { 
     @Html.ValidationSummary(true) 

    <fieldset> 
     <legend>WholeSaleModelUser</legend> 
     <table> 
      <tr> 
       <td> 
        <div class="editor-label"> 
         @Html.LabelFor(model => model.Name) 
        </div> 
       </td> 
       <td> 
        <div class="editor-field"> 
         @Html.TextBoxFor(model => model.Name) 
         @Html.ValidationMessageFor(model => model.Name) 
        </div> 
       </td> 
      </tr> 
</table> 
     <div id="partial"> 
      <table> 
       <tr> 
        <td> 
         <img id="blah" src="../../Images/no_image.jpg" alt="your image" height="200px" width="170px" /> 
        </td> 
       </tr> 
</table> 

    <script type="text/javascript"> 
     function loadUserImage() { 
      var userImg = document.getElementById("blah"); 
      var imgNm = $("#Name").value; 
      userImg.src = "D:/FEISPortal/FortalApplication/Img/" + imgNm + ".png"; 
      alert(imgNm); 
      alert(userImg.src); 
     } 
    </script> 

,我需要用我上面

@Html.TextBoxFor(model => model.Name) 

提到的JavaScript代碼,請有人告訴我如何處理上述的文字改變事件處理textchange事件本框在局部視圖文本框的代碼行。

回答

0
$document.on('blur', 'TextBox', function(){ 
    //Do something 
}); 

此格式適用於局部視圖上的任何字段。從這裏開始http://api.jquery.com/on/

相關問題