Click here to Skip to main content
15,846,038 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

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?



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[] {',', ' '},

Share this answer
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.
Share this answer
#realJSOP 30-Jun-11 10:16am    
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..
Sergey Alexandrovich Kryukov 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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900