使用不同的绑定渲染相同的局部视图

时间:2015-06-22 18:47:13

标签: jquery asp.net-mvc partial-views

在我的网站上,我有大约4个字段,最多需要使用8次。目前我在一个视图上有所有8个字段,然后如果点击链接,我使用jQuery显示和隐藏每个字段。

在我的视图模型中,我有这个

public class Example{
    public string String1 {get; set;}
    public string String2 {get; set;}
    etc..
}
public class MainClass{
    public Example example1 {get;set;}
    public Example example2 {get;set;}
    public Example example3 {get;set;}
}

然后我在我看来有类似的东西

<div id=example1>
@Html.TextboxFor(model => model.example1.String1)
@Html.TextboxFor(model => model.example1.String2)
<!-- Link to load example 2 here --> 
</div>
<div id=example2>
@Html.TextboxFor(model => model.example2.String1)
@Html.TextboxFor(model => model.example2.String2)
</div>

有没有办法找到重复的视图,所以我没有在页面加载时呈现的8个div?

由于

0 个答案:

没有答案
相关问题