Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-12-2008
Member
 
Join Date: Dec 2008
Posts: 2
C# Question, How do I assign the value of a textbox to a local variable?

I writing a small web application for my company using aspx and C#. I am new to visual C# and am still learning.

I have two text boxes, "textBox1" is for entering a note for a file, this creates a .txt file. The other textbox(TextBox2) is to enter the file number so it can name the text file accordingly. I need to assign the value of TextBox2 to a variable(filename) so that it will name the text file dynamically. I may be going about this the wrong way. Any help would be greatly appropriated. Below is the code that writes the next file.

public void Button1_Click1(object sender, EventArgs e)
{

string filename;

filename = ?????????;

StreamWriter sw = new StreamWriter(filename);

sw.WriteLine(textBox1.Text);

sw.Close();

}
Reply With Quote
  #2  
Old 10-12-2008
Member
 
Join Date: May 2008
Posts: 186
Re: C# Question, How do I assign the value of a textbox to a local variable?

Why don't you use something like:

Code:
public void Button1_Click1(object sender, EventArgs e)
{

string filename;

filename = textBox1.Text;

......

}
It will directly assign the value of your textbox to the variable.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "C# Question, How do I assign the value of a textbox to a local variable?"
Thread Thread Starter Forum Replies Last Post
Assign a text file from hard disk into a VBA string variable AbiCgail Software Development 5 15-07-2011 10:49 AM
Assign each line of a text file to a variable hitman126 Operating Systems 1 22-01-2011 07:42 AM
Excel/VBA: Copying text from UserForm Textbox to a Worksheet Textbox Neil Ives Software Development 2 20-08-2010 01:23 AM
Runtime Error 91 : Object Variable or with block variable not set Ryan21 Software Development 2 28-08-2009 07:51 PM
WSUS - Downstream / Replica / Clients pulling from local server andnot remote question. Henri@ksen Server Update Service 1 25-09-2008 02:23 AM


All times are GMT +5.5. The time now is 02:02 PM.