ASPX Engine
I have a webform with a search button. A user enters the user Id and suppose to populate a table with data.
If a user enters anything other than a Number, a message suppose to come, saying only numbers.
If the user leave the field blank and hit the search button. No results/Class found suppose to be displayed.
The PROBLEM i am having is that no matter what I put in the text field, Data still populate the table.
html
 <div align="center">
    <form id="searchUser" method="post" action="Search">
        <table align="center">
    <tr>
        <td class="label">
            Enter ID:
        </td>
        <td>
            <input type="text" name="UserId" id="UserId" value="<%=(string)(ViewBag.userid)%>" />
        </td>
    </tr>
    <tr>
        <td>
            <button class="searchButton" id="searchButton">Search</button>
        </td>
    </tr>
  </table>
 </form>
   </div>
   <hr /> 
   <% if (ViewBag.searchClass !=null)
     { %>
     <h2>Search Resuls</h2>
     <br />
     <%AAlexUsers.Models.SearchClass searchClassList= ViewBag.searchClass;%>
     <table>
        <tr>
            <td>
                UserID:
            </td>
            <td class="content">
              <%=searchClassList.userId%>
            </td>
        </tr>
        <tr>
            <td>
                Email:
            </td>
            <td class="content">
             <%=searchClassList.email%>
            </td>
        </tr>
    <tr>
        <td>
        Last Four Digits:
        </td>
        <td class="content">
          <%=searchClassList.lastFourdigits%>
         </td>
    </tr>
 </table>
    <%} else %>
 <%{ %>
    <h2>No Class found.</h2>
 <%} %>
Controller
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.Message = "Welcome to ASP.NET MVC!";
        return View();
    }
    public ActionResult About()
    {
        return View();
    }
    public ActionResult Search()
    {
        string userId = Request["UserId"];
        bool view = false;
        if (Request["UserId"] == null)
        {
            view = true;
        }
        if (!view)
        {
            AAlexUsers.Models.SearchClass searchClass = new Models.SearchClass();
            {
                searchClass.lastFourdigits = "2222";
                searchClass.userId = userId;
                searchClass.email = "diaz@gmail.com";
                string lastFourdigits = searchClass.lastFourdigits;
                string userIdd = searchClass.userId;
                string email = searchClass.email;
                ViewBag.searchClass = searchClass;
                ViewBag.lastFourdigits = lastFourdigits;
                ViewBag.userId = userIdd;
                ViewBag.email = email;
            }
        }
        return View();
    }
}
Model
public class SearchClass
{
    public string userId { get; set; }
    public string email { get; set; }
    public string lastFourdigits { get; set; }
    public SearchClass()
    {
        userId = "";
        email = "";
        lastFourdigits = "";
    }
}
 
     
    