@foreach (var item in outcode)
{
var outc = item;
if (!codedata.Contains(outc))
{
codedata.Add(outc);
}
else
{
Fun();
}
}
//this is my C# code and here else condition call JavaScript function.
function fun() {
$("table").append('<tr><th><button class="btn btn-secondary" type="button">@Session["dd"]</button> </th> </tr>');
}
//这是JavaScript函数。 并且在其他条件以剃刀代码执行时调用此函数。
答案 0 :(得分:0)
希望这会有所帮助
<script type="text/javascript">
function fun()
{
alert('You clicked '+ name +"!");
}
</script>
<div>
<table class="table table-bordered table-condensed">
<tr>
<th>Name</th>
<th>Department</th>
<th>Action</th>
</tr>
@foreach (Employee emp in Model)
{
<tr>
<td>
<a onclick="AlertName('@String.Format("{0} {1}", emp.FirstName, emp.LastName)')" href="#">@String.Format("{0} {1}", emp.FirstName, emp.LastName)</a>
</td>
<td>
</td>
</tr>
}
</table>
</div>