说明:
closewindow ->关闭当前页面;
submitname ->如果选择了联系人,则设置该页面返回值,并关闭当前页面;
getTreeNode ->获得当前click的node,设置选中节点颜色为选中颜色,如果之前选中了其他节点,则恢复之前选中节点的颜色为未选中的颜色;同时设置lblUser显示选中的联系人。
子页面在页面加载时,需要加载联系人树,后台代码如下:
public partial class ChildPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TreeViewContactList.Attributes.Add("onclick", "javascript:return getTreeNode();");
string[] groups = {"朋友", "同学" };
List<Person> friends = new List<Person>();
friends.Add(new Person("朋友A","Peter"));
friends.Add(new Person("朋友B", "John"));
friends.Add(new Person("朋友C", "Clare"));
List<Person> classmates = new List<Person>();
classmates.Add(new Person("同学1", "Lili"));
classmates.Add(new Person("同学2", "Bob"));
classmates.Add(new Person("同学3", "Steve"));
Dictionary<string, List<Person>> contacts = new Dictionary<string, List<Person>>();
contacts.Add(groups[0], friends);
contacts.Add(groups[1], classmates);
foreach (string group in groups)
{
  |