Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,696 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,490 people online right now. Registration is fast and FREE... Join Now!




how to use a text box

 
Reply to this topicStart new topic

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

srik
post 8 Oct, 2008 - 04:31 AM
Post #1


New D.I.C Head

*
Joined: 6 Oct, 2008
Posts: 4

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


CODE

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
User is offlineProfile CardPM

Go to the top of the page


zakary
post 8 Oct, 2008 - 04:35 AM
Post #2


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 400



Thanked 6 times

Dream Kudos: 175
My Contributions


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
csharp

// 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: 8 Oct, 2008 - 04:38 AM
User is offlineProfile CardPM

Go to the top of the page

srik
post 8 Oct, 2008 - 05:01 AM
Post #3


New D.I.C Head

*
Joined: 6 Oct, 2008
Posts: 4

QUOTE(zakary @ 8 Oct, 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
csharp

// 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?
User is offlineProfile CardPM

Go to the top of the page

zakary
post 8 Oct, 2008 - 05:08 AM
Post #4


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 400



Thanked 6 times

Dream Kudos: 175
My Contributions


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.microsoft.com/en-us/library/sy...ack(VS.71).aspx
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 8 Oct, 2008 - 07:24 AM
Post #5


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,909



Thanked 116 times

Dream Kudos: 8450

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Moved to ASP.NET smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 08:40AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month