当前位置:编程学习 > C#/ASP.NET >>

关于C#个性化配置

按照入门经典里面的步骤,设置了个性化配置


这里不太清楚第三个标签为什么总是显示下拉列表里原来选择的内容。
最后的文本框就可以同步显示下拉列表的选择
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DropDownListCountries.SelectedValue = Profile.Country;
        }

        LabelLastVisit.Text = Profile.LastVisit.ToLongTimeString();
        LabelVisitCount.Text = Profile.Visits.ToString();
        LabelSelectedCountry.Text = Profile.Country;

        Profile.Visits++;
        Profile.LastVisit = DateTime.Now;

    }
    protected void OnCountrySelection(object sender, EventArgs e)
    {
        Profile.Country = this.DropDownListCountries.SelectedValue;
        Profile.Save();
        test.Text = this.DropDownListCountries.SelectedValue;
    }


        LabelLastVisit.Text = Profile.LastVisit.ToLongTimeString();
        LabelVisitCount.Text = Profile.Visits.ToString();
        LabelSelectedCountry.Text = Profile.Country;
    把这段移到OnCountrySelection里就可以同步显示了。
    求助各路大神!谢谢 --------------------编程问答-------------------- 支持!!!!!!!!!!! --------------------编程问答-------------------- 没人回答啊,感觉应该很多人知道啊 --------------------编程问答-------------------- 通过调试终于搞清楚了 设置autopostback为true,当selectedindexchanged事件发生时,先重新执行page_load,然后才是事件绑定的函数OnCountrySelection,所以那个country标签总是显示的前一个profile的country值
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,