我正在使用MVC-4創建移動網站。mvc EditorTemplate DisplayMod
整型字段應該從數字鍵盤輸入,我用的是EditorTemplate number
至極創建一個像這樣的HTML元素:
<input ... type="number" value="45" />
我的客戶不欣賞他的iPhone出這樣的數字鍵盤並要求我顯示使用type="tel"
而不是type="number"
顯示的電話鍵盤。
我正在努力如何在我的EditorTemplate number.cshtml
中完成此操作。
我創建了一個獨立的iPhone DISPLAYMODE但我不知道如何使用它與EditorTemplate結合,我試圖將其複製到number.iPhone.cshtml
但EditorTemplates似乎不工作的方式......
有一些方法來檢索當前的DisplayMode所以我可以解決這個問題?
// pseudo code I guess …
@if(DisplayMode == "iPhone")
{
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "text-box single-line", type = "tel" })
}
else
{
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "text-box single-line", type = "number" })
}
我一直在我的模型中測試這個'int',期望使用'Number.cshtml',因爲事實證明它使用'Int32.cshtml'作爲'int'(offcourse)。所以現在它工作得很好。 謝謝! – Jurjen