Click here to Skip to main content
12,635,011 members (29,098 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET

I have a TextBox control where i am using Ajax AutoComplete extender for the end user to enter email address of the people they want to save separated by a comma, my problem is that in code behind I want to read each email address entered by the user separately so that i can save it as an individual record in the database, How do i Read each email address separately code behind?


Posted 30-Jun-11 4:50am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The solution by Sugato show correct idea, but there are number of bugs in code.
This is safer version of the split method:

string [] emailArr =
        new char[] {',', ' '},

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

you can use String.Split function to separate the comma separated email address.
If you use String.Split(',') thn in the output you will get an array of those email addresses.the code ll be as follows:

string strEmailaddress = Textbox.text;
string [] EmailArr = strEmailAddress.split(',');

Now if there is multiple value then the array will be

EmailArr[]={"", ""};

Now you can take single element from this array by EmailArr[0] and EmailArr[1],
and can insert into DB.

Hope this will help you.
I fixed spelling errors, added tags to highlight code, and corrected some sytax errors in the code.
Sugato Pal 30-Jun-11 11:00am
Thanks John..
cnjadhav 30-Jun-11 15:17pm
thanks buddy.!! this what i was looking for, works great..just did some tweeks to make it strEmailAddress.split(new char[] {','},StringSplitOptions.RemoveEmptyEntries);
Sugato Pal 1-Jul-11 3:52am
grt..i am really happy to hear that it helps if you really like it i will be greatful if you rate it.Thanks..
SAKryukov 1-Jul-11 23:57pm
Sorry, I voted 3 due to some bugs in code. Please check up before posting.
Property Text and the method Split are capitalized; Split requires array of char, not char.
Please see my answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 1 Jul 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100