[英]how to handle partial view elements in javascript
請參考此代碼,它是使用mvc開發的Web應用程序的部分視圖。
@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>
我需要使用上面提到的javascript代碼在部分視圖中處理此文本框的textchange事件
@Html.TextBoxFor(model => model.Name)
請有人告訴我如何處理文本框以上代碼行的文本更改事件。
$document.on('blur', 'TextBox', function(){
//Do something
});
此格式應適用於部分視圖上的任何字段。 從這里http://api.jquery.com/on/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.