I have an text box and I want split its text and print that splited text in different labels. suppose I text box user writes Ravi Bhushan now I want spit it in two labels each after the space (In first label Ravi and in second label Bhushan. In ASP.net using c#
protected void btnSubmit_Click(object sender, EventArgs e)
{
string Name = txtName.Text.ToString();
char[] seperators = new char[] {' '};
string[] splitedName = Name.Split(seperators);
foreach (string s in splitedName)
{
//System.Console.WriteLine(s);
lblFst.Text = s.ToString();
}
}
If I use above code then in LblFst where I want to print Ravi it is printing Bhushan