当前位置: 代码迷 >> .NET组件控件 >> 内容页给自定义控件赋值后,自定义控件调用本身的值时属性值为空,这是什么情况
  详细解决方案

内容页给自定义控件赋值后,自定义控件调用本身的值时属性值为空,这是什么情况

热度:4238   发布时间:2013-02-25 00:00:00.0
内容页给自定义控件赋值后,自定义控件调用自身的值时属性值为空,这是什么情况?
我写了个用户控件ShowLoginBar,在内容页给用户控件的属性toURL赋了值,但是用户控件自身调用这个值的时候toURL的值却为空。我是菜鸟,大家多多帮忙啊!急急急急急急急!

自定义控件ShowLoginBar.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Web.Security;

namespace TraineeManagementSystem.Include.Ascx
{
    public partial class ShowLoginBar : System.Web.UI.UserControl
    {
        public string RootPath;
        private string toURL;
        /// <summary>
        /// toURL弹出登录框跳转的路径
        /// </summary>
        public string ToURL
        {
            get { return toURL; }
            set { toURL = value;  }
        }
        private string thisURL;
        /// <summary>
        /// toURL弹出登录框跳转的路径
        /// </summary>
        public string ThisURL
        {
            get { return toURL; }
            set { toURL = value; }
        }
        private static string thisToUrl;
        protected void Page_Load(object sender, EventArgs e)
        {
            RootPath = TraineeManagementSystem.Code.GetFilePath._ApplicationPath;
        }
        protected void lnkPWD_Click(object sender, EventArgs e)
        {
            Session["tabNumber"] = "3";
            Response.Redirect("aq.aspx");
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //创建链接字符串
            string conStr = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
            //创建数据库链接
            SqlConnection con = new SqlConnection(conStr);
  相关解决方案