我有一个带有文本框的小网页,我希望它只输入数字。我怎样才能在 C# 方面做到这一点。请帮我!我在想我需要一个 if 语句说if(userId = xxx !numbers)
然后留言显示请输入一个数字。我想不通。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace AlexUsers.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
string userId = Request["UserId"];
return View();
}
}
}
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Search</title>
</head>
<div align="center">
<form id="searchUser" method="post" action="">
<table align="center">
<tr>
<td class="label">
Enter ID:
</td>
<td>
<input type="text" name="UserId" id="UserId" />
</td>
</tr>
<tr>
<td>
<button class="searchButton" id="searchButtong">Search</button>
</td>
</tr>
</table>
</form>
</div>
<hr />
</html>