RETURNING A VALUE FROM TEXTBOX IN A CLASS

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
C#  ASP.Net 
 846  View(s)
Ratings:
Rate this:

I have a text box in my form. I have a class TicketUser where i have accessors set to return a a value in my label. Im trying to get the value from the text box inside the label. I'm trying to get firstName to return a value of txtfirstName.Text from my form. Can someone please guide me in the right direction please. Im pretty new to asp.net

 

public class TicketUser

{

    public string firstName;

    public string lastName;

    public string username;

    TicketForm form = new TicketForm();

 

    //property accessors

  public string CreateAccountMessage

    {

        get

        {

            return "Congratulations" + firstName + "Your account has been created. Your username is" + username;

        }

        set

        {

            CreateAccountMessage = value;

        }}

    //CreateAccount method

    public string CreateAccount()

    {

        return CreateAccountMessage;

    }}}

  1. john rob

    Post:108

    Points:756
    Re: Returning a value from textbox in a class

    I hope i got you correct because you need to some details about what you are trying to do and what are the results. Make and Object of TicketUser in the code behind file of the form and set

     

    t = new TicketUser();

    t.firstName=txtfirstName.Text;

    t.lastName=txtlastName.Text;

    t.userName=txtUsername.Text;

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Returning a value from textbox in a class

    Change this:

     

    public string firstName = "";

    public string lastName = "";

    public string username = "";

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!