how to use a text box

I am using a text box in my application(webpage).i would like to know

Page 1 of 1

4 Replies - 1499 Views - Last Post: 08 October 2008 - 08:24 AM Rate Topic: -----

#1 srik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-October 08

how to use a text box

Posted 08 October 2008 - 05:31 AM

I am using a text box in my application(webpage).i would like to know a basic information. if a person enters a text in that textbox how shall i move that to my code.


thanx in advance
srik


protected void Button1_Click(object sender, EventArgs e)
	{
		System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

		System.Net.NetworkCredential cred = new System.Net.NetworkCredential("from@gmail.com", "password");

		mail.To.Add("to@gmail.com");
		mail.Subject = "subject goes here";

		mail.From = new System.Net.Mail.MailAddress("from@gmail.com");
		mail.IsBodyHtml = true;
		mail.Body = "hi this is a test mail";
		System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
		smtp.UseDefaultCredentials = false;
		smtp.EnableSsl = true;
		smtp.Credentials = cred;
		smtp.Port = 587;
		smtp.Send(mail);

	}



how to make the to address as a textboxentry

Is This A Good Question/Topic? 0
  • +

Replies To: how to use a text box

#2 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: how to use a text box

Posted 08 October 2008 - 05:35 AM

The following will work but you will want to do more validation on that text to make sure it is a valid email address format
// check to see if text box has a string value
if(!string.IsNullOrEmpty(textboxentry.Text)
{
    // add the text box value to mail.To
    mail.To.Add(textboxentry.Text);
}


This post has been edited by zakary: 08 October 2008 - 05:38 AM

Was This Post Helpful? 0
  • +
  • -

#3 srik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-October 08

Re: how to use a text box

Posted 08 October 2008 - 06:01 AM

View Postzakary, on 8 Oct, 2008 - 05:35 AM, said:

The following will work but you will want to do more validation on that text to make sure it is a valid email address format
// check to see if text box has a string value
if(!string.IsNullOrEmpty(textboxentry.Text)
{
    // add the text box value to mail.To
    mail.To.Add(textboxentry.Text);
}





Thanx for the information.
neways how to check whether it is a valid email format or not. how to clear the text box after clicking send. what is Autopostback?
Was This Post Helpful? 0
  • +
  • -

#4 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: how to use a text box

Posted 08 October 2008 - 06:08 AM

there are ways of checking but if i give you all the answers how will you ever learn google is your friend I just google'd C# Autopostback and here is the MSDN link
http://msdn.microsof...ack(VS.71).aspx
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to use a text box

Posted 08 October 2008 - 08:24 AM

Moved to ASP.NET :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1