Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:37:25+00:00 2026-06-11T21:37:25+00:00

ASPX Engine I have a webform with a search button. A user enters the

  • 0

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 = "";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:37:26+00:00Added an answer on June 11, 2026 at 9:37 pm

    Change this line …

    if (Request["UserId"] == null)
    

    … to this …

    if (string.IsNullOrEmpty(userId))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an ASPX application that collects data from the user can creates
I have a theme in blog engine.net I want to reference a .aspx file
I have a search engine that is supposed to search through descriptions of products
I'm using the spark view engine with my asp.net mvc application. In my aspx
Aspx Page: $(document).ready(function() { $(#btnn).click(function() { $.ajax({ type: POST, url: TestPage.aspx/emp, data: {}, contentType:
I have an aspx web form in a WCF service project that gives a
I have two aspx pages: DashboardPreview.aspx: This is the homepage. It shows top 5
On a aspx page, I have to load a DropDown with some values coming
I have a comment form on my website on contact.aspx . I want to
Do asp.net aspx views have tags that that work similar to the Ruby erb

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.