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 8652203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:15:18+00:00 2026-06-12T14:15:18+00:00

So I am trying to make the user input information that displays after clicking

  • 0

So I am trying to make the user input information that displays after clicking a button. I get the message but it doenst show the value input into the textbox. What am I missing?
here is my code

private string _eyecolor;
    public string Eyecolor
    {
        get { return _eyecolor; }
        set
        {
            if (!string.IsNullOrEmpty(value))
            {
                _eyecolor = value.Substring(0, 1).ToUpper() + value.Substring(1);
            }
            else
            {
                _eyecolor = value;
            }
        }
    }

    public string getEyeColor()
    {
        return "You have " + _eyecolor + "eyes!!";
    }

Here is my html code:

     <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Label runat="server" ID="lbl_1" AssociatedControlID="txtb1" Text="what is your eyes color?" Autopostback="true" />
    <asp:TextBox ID="txtb1" runat="server" />
    <asp:Button ID="btn_submit" Text="Submit" runat="server" OnClick="subSubmit" />
    <asp:Label runat="server" ID="lbl_output" />
    </div>
    </form>
</body>
</html>

and my codebehind:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
   Profile P = new Profile();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
protected void  subSubmit(object sender, EventArgs e)
{
   lbl_output.Text=P.getMsg();
   lbl_output.Text+=P.getEyeColor();
}
}
  • 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-12T14:15:19+00:00Added an answer on June 12, 2026 at 2:15 pm

    As Adil quite rightly pointed out, you need to grab the value from the <asp:TextBox> input and assign it to your property Eyecolor.

    Since getEyeColor is a function of the Profile object P in your posted code, try changing your Submit handler to the following:

    protected void subSubmit(object sender, EventArgs e)
    {
        P.Eyecolor = txtb1.Text.Trim; //Add this to set the Eyecolor to user input.
        lbl_output.Text = P.getMsg();
        lbl_output.Text += P.getEyeColor();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to make a simple program that takes the user input, until
I'm trying to make a simple command that pauses for user input. I think
I am trying to make a button for the user where he will be
I'm trying to make a simple application form were user can input data like
I'm trying to display text that is input by the user if it is
I'm trying to make an app where a user inputs some information and then
I'm trying to make my program check for bad user input. In this case,
I am trying to make nice looking user input buttons for my app. Just
I am trying to make error free user input. When there is a one
I'm trying to make a program that prompts the user for 2 items -

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.