ASP.NET - regarding the adding of names in mail option

Asked By amala mandarapu on 28-Feb-12 06:40 AM
hi all,
please check this once.

if (txtFacultyName.Text.ToString().Contains(","))



"Faculty Name : " + txtFacultyName.Text.ToString().Remove(txtFacultyName.Text.ToString().LastIndexOf(",")));




sb.Append("Faculty Name : " + txtFacultyName.Text.ToString());


in this when i am giving names as abc,def it is removing def and displaying only my question is i want to display all the values present in this textbox.please check above code and tell me where to change.
dipa ahuja replied to amala mandarapu on 28-Feb-12 06:46 AM
use the split function to split the values

string s = "Hello,World!";
string[] data = s.Split(',');
string firstname = data[0].ToString();//contan hello
string lastname = data[1].ToString(); //contan word
amala mandarapu replied to dipa ahuja on 28-Feb-12 06:51 AM
my doubt is i am giving to names at a time in the textbox as amala,mandarapu andclicking on the save button then automatically we will get a mail but in that only amala is dispalying and it is removing mandarapu.
now my question is i want to dispaly both the names without removing.
please tell any change in code.
D Company replied to amala mandarapu on 28-Feb-12 11:54 AM
yes , i got the problem u are facing , see this its working fine

string name = "amal,mandarapu";//assign this string to the value of textbox,and cehck if contains , that code u have already mentioned, and than split and add again
string[] data = name.Split(',');
string newname = data[0] + data[1];

it will work