---
title: "Returning a value from textbox in a class"  
description: "Returning a value from textbox in a class"  
author: "Anonymous User"  
published: 2014-12-18  
updated: 2014-12-19  
canonical: https://www.mindstick.com/forum/12791/returning-a-value-from-textbox-in-a-class  
category: ".net"  
tags: ["c#", "asp.net"]  
reading_time: 2 minutes  

---

# Returning a value from textbox in a class

I have a text box in my [form](https://www.mindstick.com/forum/6/multi-form-mfc-application). I have a [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) TicketUser where i have accessors set to return a a [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) in my label. Im [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to get the value from the text box inside the label. I'm trying to get [firstName](https://www.mindstick.com/interview/33973/how-to-split-the-full-name-into-firstname-and-lastname-in-sql-server) to return a value of txtfirstName.Text from my form. Can someone please [guide](https://www.mindstick.com/articles/44463/business-to-business-vat-reclaiming-a-guide-for-your-employees) me in the [right direction](https://yourviews.mindstick.com/story/1002/daily-30-minutes-in-the-right-direction-can-change-the-entire-day-s-mood) please. Im pretty new to [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder)

```
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;    }}}
```

## Replies

### Reply by Pravesh Singh

Change this:

public string firstName = "";

public string lastName = "";

public string username = "";

### Reply by Anonymous User

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;


---

Original Source: https://www.mindstick.com/forum/12791/returning-a-value-from-textbox-in-a-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
