在ASP.NET MVC 3帮手Tab顺序 [英] Tab Order in ASP.NET MVC 3 Helpers

查看:122
本文介绍了在ASP.NET MVC 3帮手Tab顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Tab键顺序财产以下code:

How can I use Tab Order property for following code:

<td>
    @Html.EditorFor(model => model.Cost)                
</td>

我试过这样:

<td tabindex=1>
    @Html.EditorFor(model => model.Cost)                
</td>

有什么建议?

推荐答案

作为对比@ Stuy1974的正确的答案,如果你不想离开 EditorFor 解决方案,你将不得不线了自己的<一个href=\"http://blogs.msdn.com/b/nunos/archive/2010/02/08/quick-tips-about-asp-net-mvc-editor-templates.aspx\">Editor模板。

As a contrast to @Stuy1974's right answer, if you don't want to leave the EditorFor solution, you're going to have to wire up your own Editor Template.

@ModelType SomeApp.ViewModels.SomeNiftyViewModel 

// be sure to include the TabIndex info in the ViewModel
@Html.TextBoxFor(model => model.Cost, new { tabindex = model.TabIndex })

您也可以使用已经传递给编辑模板ViewData的参数,而不是直接将标签索引模型:

You can also use the ViewData parameter already passed to the editor template directly rather than adding the tab index to the model:

// In the main view
@Html.EditorFor(model => model.Cost, new { TabIndex = 3 })

// In the editor template
@{ int tabIndex = (ViewData["TabIndex"] as int?) ?? 0; }
@Html.TextBoxFor(model => model, new { tabindex = tabIndex })

这篇关于在ASP.NET MVC 3帮手Tab顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆