Javascript 如何将数据传输到<;部门>;在ASP.NET MVC中
我有一个按钮:Javascript 如何将数据传输到<;部门>;在ASP.NET MVC中,javascript,html,asp.net,asp.net-mvc,visual-studio-2010,Javascript,Html,Asp.net,Asp.net Mvc,Visual Studio 2010,我有一个按钮: a href='javascript:void(null)' onclick = "showDialog()" class='btn_history' id='@Model.contractFees.ElementAt(loop).FeeId' title='History'>History 这将调用此脚本: <script type ="text/javascript"> function showDialog() { $("#history_dia
a href='javascript:void(null)' onclick = "showDialog()" class='btn_history' id='@Model.contractFees.ElementAt(loop).FeeId' title='History'>History
这将调用此脚本:
<script type ="text/javascript">
function showDialog() {
$("#history_dialog").dialog({
modal: true,
draggable: false,
resizable: false,
width: 600,
buttons: {
"Okay": function () {
$(this).dialog("close");
}
}
});
}
我曾尝试将值传递到脚本、将值传递到模型和ViewBag中,但没有成功。我的问题是如何将按钮id作为div中的值获取
使用Ajax,进行异步调用,并将所需数据作为JSON对象返回。为了在单击按钮时“刷新”div,当AJAX调用返回时,您应该将其放在单独的局部视图中,并在成功时重新填充它。div在哪里(在同一个文件中还是在另一个文件中)?如果它在同一个文件中,您不能使用服务器数据,因为您不向服务器发出任何请求。所有操作都在浏览器中完成,您无法访问服务器数据。按下按钮时,应该进行AJAX调用并检索JSON数据。然后填充数据。您正在打开的对话框已经出现在页面上,因此您无法使用jquery执行此操作。“我已尝试将值传递到脚本中”如何执行此操作
<div id='history_dialog' title="Contract Fee History" style="display: none">
<fieldset>
<input type="hidden" id="row_id" name="row_id" value="" />
<table id='historyOFee' width="100%" class="tan">
<thead>
<tr class="top">
<th>Effective Date</th>
<th>End Date</th>
<th>Fee %</th>
</tr>
</thead>
<tbody>
@foreach (ContractFee fee in Model.fullListOfFees.ToList())
{
<tr>
<td>
<text>@fee.EffectiveDate</text>
</td>
<td>
<text>@fee.EndDate</text>
</td>
<td>
<text>@fee.FeeRate</text>
</td>
</tr>
}
</tbody>
</table>
</fieldset>
@foreach(ContractFee fee in Model.fullListOfFees.where(x =>x.ID == buttonId)