如何让我的文本框中只取数字? [英] How do I make my text box only take numbers?
问题描述
我想设置它,这样你只能在文本框中输入值,简单明了。但是图片显示的结果我得到。任何想法是什么问题?我有一个文本框设置了这样的几个月前,所以我知道什么东西在行,如果这应该工作。
I want to set it so that you can only input values in the textbox, plain and simple. But the picture shows the result I get. Any idea what the problem is? I had one text box set up like this a few months back so I know that something in the lines if this should work.
HTML code:
Html code:
if (Roles.IsUserInRole(WebSecurity.CurrentUserName, "Admin"))
{
@:<p><b>Customer ID:</b> @Html.TextBox("SearchString2", new {@type="number"})</p>
}
先谢谢了。
推荐答案
您使用 Html.TextBox错误的过载()
(<一个href=\"https://msdn.microsoft.com/en-us/library/system.web.mvc.html.inputextensions.textbox(v=vs.118).aspx#M:System.Web.Mvc.Html.InputExtensions.TextBox%28System.Web.Mvc.HtmlHelper,System.String,System.Object%29\"相对=nofollow>这个),其中第二个参数是要显示的值。你需要使用<一个href=\"https://msdn.microsoft.com/en-us/library/system.web.mvc.html.inputextensions.textbox(v=vs.118).aspx#M:System.Web.Mvc.Html.InputExtensions.TextBox%28System.Web.Mvc.HtmlHelper,System.String,System.Object,System.Object%29\"相对=nofollow>这个
Your using the wrong overload of Html.TextBox()
(this one) where the second parameter is the value to display. You need to use this one
@Html.TextBox("SearchString2", null, new { @type="number" })
这篇关于如何让我的文本框中只取数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!