Asp.net mvc razor读取传递给modal的值

时间:2016-03-27 14:29:43

标签: asp.net-mvc twitter-bootstrap razor

我有一个列表按钮,它传递指标Id并打开bootstrap模态。我找到了如何传递这个值,但没有找到如何得到它。这是我的代码:

@model Project.Models.Survey

@{
    var i = 1;
}

@foreach (var Clasificator in Model.Clasificators)
{
    <h2>@Clasificator.Name</h2>
    <br/>
    foreach (var Criteria in Model.Criterias)
    {
        if (Criteria.ClasificatorId == Clasificator.Id)
        {
            <h3>@Criteria.Name</h3>
            <br/>
            foreach (var Indicator in Model.Indicators)
            {
                if (Indicator.CriteriaId == Criteria.Id)
                {
                    <h4> @i @Indicator.Name </h4>
                    <br/>
                    <button id="@Indicator.Id" type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" data-indicatorId="@Indicator.Id">
                        Add New Object
                    </button>    
                    i++;
                }
            }
        }
    }
}


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
            </div>
            <div class="modal-body">
               // Catch here indicator Id
               If (indicatorId)
               {}

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

有可能抓住它吗?我需要在其他if中使用该值。

0 个答案:

没有答案