zoukankan      html  css  js  c++  java
  • 从用户控件(ASCX)变更网页(ASPX)一些值

    问题与要求是这样的。网页ASPX有一个Label,此也是TextBox的Title。

    还有几个用户控件ASCX,每个ASCX都有一个属性。网页会根据实际情况的需要而去动态加载这些用户控件。在加载时,网页ASPX的TextBox的Title的Label的文字会根据加载的用户控件的属性而改变。写得有点呦口。

     下面Insus.NET在几个用户控件中,只列写一个,因为语法一样,只是属性值不一样。 

    UserControlA
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class UserControlA : System.Web.UI.UserControl
    {
        private string _TextBoxTitle;

        public string TextBoxTitle
        {
            get { return _TextBoxTitle; }
            set { _TextBoxTitle = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this._TextBoxTitle = "Name";
        }
    }

    当用户控件动态加载至aspx之后,运行:

     在aspx网页,动态把用户控件ascx的属性赋值给Label。

    View Code
    protected void Page_Load(object sender, EventArgs e)
        {
           this.UserControlA1.PreRender += new EventHandler(UserControlA1_PreRender);
        }

        void UserControlA1_PreRender(object sender, EventArgs e)
        {
            string strLabel = this.UserControlA1.TextBoxTitle;
            this.Label1.Text = strLabel;
        }
  • 相关阅读:
    Vue(七)-- 插件
    Vue(六)-- 过滤器、常用内置指令、自定义指令
    Vue(五)-- 生命周期
    Vue(四)-- 事件处理(绑定监听、按键修饰符、取消冒泡、阻止默认事件),v-model的使用
    Two Sum 两数之和
    使用原生JavaScript实现sleep函数
    感恩
    关于AJAX的总结和思考-2
    关于AJAX的一点总结与思考-1
    DNS解析和前端优化点之一
  • 原文地址:https://www.cnblogs.com/insus/p/2749880.html
Copyright © 2011-2022 走看看