using System;
using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Text.RegularExpressions;string sAnswer = ""; string[] Answer = Regex.Split(lbQuestion.Text, "_+", RegexOptions.IgnoreCase); for (int i = 0; i < (Answer.Count() - 1); i++) { if (Answer[0] == "") { Answer[0] = "<input type=\"text\" id=txtRightAnswer" + 0 + " style=\"background-color:#ceedff; border:none; border-bottom:solid 1px black;\" />"; } else if (i == (Answer.Count() - 1) && Answer[(Answer.Count() - 1)] == "") { Answer[(Answer.Count() - 1)] = "<input type=\"text\" id=txtRightAnswer" + (Answer.Count() - 1) + " style=\"background-color:#ceedff; border:none; border-bottom:solid 1px black;\" />"; } else { Answer[i] += "<input type=\"text\" id=txtRightAnswer" + i + " style=\"background-color:#ceedff;border:none; border-bottom:solid 1px black;\" />"; } } for (int j = 0; j < Answer.Length; j++) { sAnswer += Answer[j]; } Control c = ParseControl(sAnswer); Panel1.Controls.Clear(); Panel1.Controls.Add(c);