---
title: "Passing Text Box Values from a user control file to another class file"  
description: "Passing Text Box Values from a user control file to another class file"  
author: "Anonymous User"  
published: 2014-11-27  
updated: 2014-11-28  
canonical: https://www.mindstick.com/forum/12709/passing-text-box-values-from-a-user-control-file-to-another-class-file  
category: "asp.net"  
tags: ["c#", "asp.net"]  
reading_time: 2 minutes  

---

# Passing Text Box Values from a user control file to another class file

I [am looking](https://answers.mindstick.com/qa/115463/i-am-looking-for-to-joining-the-mindstick-internship-program-how-to-apply) to pass values over from an ascx.cs [user control](https://www.mindstick.com/forum/294/problem-in-access-the-control-inside-the-user-control) file to another [class file](https://www.mindstick.com/forum/60/how-we-add-dll-with-other-class-file) in my [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects). I need to be able to get the values of the [dynamic](https://www.mindstick.com/blog/11080/features-of-java-dynamic-complied-and-interpreted) [text boxes](https://www.mindstick.com/forum/34261/how-to-split-data-to-text-boxes-when-read-qr-code-data) from the user control to be able to put them in a [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax).

Here is what I have so far

## User Control File

```
public void Page_Load(object sender, EventArgs e)    {        ItemBox.Text = Request.Form[ItemBox.UniqueID];        NumberBox.Text = Request.Form[NumberBox.UniqueID];        DescriptBox.Text = Request.Form[DescriptBox.UniqueID];     }
```

## Other class file

```
 ViewState[VIEWSTATEKEY] = nt.Parse(ViewState[VIEWSTATEKEY].ToString()) + 1;        LoadPageControls();        RowID ++;         string box1value = Request.Form[ItemBox.Text];        string box2value = Request.Form[NumberBox.UniqueID];        string box3value = Request.Form[DescriptBox.UniqueID];         string sConnection = generic database address;
```

I have seen other people using a get method to pull the data over. But I can't get the syntax right and it keeps giving errors.

I tried this because I saw it here C# Get [textBox value](https://www.mindstick.com/forum/33830/how-to-calculate-data-grid-value-and-textbox-value-on-change-in-vb-dot-net-winform) from another class and thought it would work, but with no joy

string box1value{ get {return ItemBox.Text;} }

There is most likely something simple that I am missing here but I have been stuck on this [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) for a couple off weeks now and it is driving me up the walls trying to get this project finished so any help that you can give would be much appreciated.

## Replies

### Reply by Anonymous User

User [Control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) File

```
public void Page_Load(object sender, EventArgs e){   
Session["ItemBox"] = Request.Form[ItemBox.UniqueID];   
Session["NumberBox"] = Request.Form[NumberBox.UniqueID];   
Session["DescriptBox"] = Request.Form[DescriptBox.UniqueID];}
```

Other class file

```
var ItemBox = (Session["ItemBox"] ??"").ToString();var NumberBox= (Session["NumberBox"] ??"").ToString();var DescriptBox= (Session["DescriptBox"] ??"").ToString();
```


---

Original Source: https://www.mindstick.com/forum/12709/passing-text-box-values-from-a-user-control-file-to-another-class-file

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
