forum

Home / DeveloperSection / Forums / Passing Text Box Values from a user control file to another class file

Passing Text Box Values from a user control file to another class file

Anonymous User 2010 27-Nov-2014

I am looking to pass values over from an ascx.cs user control file to another class file in my project. I need to be able to get the values of the dynamic text boxes from the user control to be able to put them in a database. 

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 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 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.


Updated on 28-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By