我在我的项目中使用 MVC2。我在“.aspx”页面中有此代码,用于确定是否应显示“.ascx”页面:
<% if(Model.MRxECG != null) { %>
<div id="ecg">
<% Html.RenderPartial("ecgDetails", Model); %>
</div>
<% } %>
这是“.ascx”页面中的代码。
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Intranet.Models.CareRecord.CareRecordSummaryModel>" %>
<script type="text/javascript">
function resImage(image)
{
var resize = 200; // amount in percentage
var oldheight = 150; // height of your image
var oldwidth = 250; // width of your image
var X = event.x;
var Y = event.y;
var newHeight = oldheight * (resize / 100);
var newWidth = oldwidth * (resize / 100);
image.style.height = newHeight;//height of new image
image.style.width = newWidth;// width of new image
var c = image.parentNode;
c.scrollLeft = (X * (resize / 100)) - (newWidth / 2) / 2; //this is for
c.scrollTop = (Y * (resize / 100)) - (newHeight / 2) / 2;//new center
}
</script>
<div>
<table class="layout" width="900px">
<tr>
<td>
<img src='<%= Url.Action("ShowMRx12LeadImage", "CareRecord", new { id = Model.CareRecord.CaseNumber}) %>'
alt="12-Lead ECG" style="width: 1000px; height: 800px;" onmouseover="resImage(this)" />
</td>
</tr>
</table>
</div>
图像不会放大鼠标悬停事件。我尝试将 Javascript 代码放在“.aspx”页面中,但没有用。我应该怎么做才能完成这项工作?
我不确定 Javascript 是否可以在 .ascx 页面中使用。我必须使用 jQuery 来实现放大功能吗?