示例#1
0
        /// <summary>
        /// 在网页中装载一个视图
        /// </summary>
        /// <param name="control">要添加视图的控件</param>
        /// <param name="viewpath">视图路径.注:不带文件后缀</param>
        /// <param name="model">数据模型,该值可为null</param>
        public virtual MvcView LoadViewToControl(Control control, string viewpath, object model)
        {
            MvcView mv = this.CreateView(viewpath, model);

            control.Controls.Add(mv);
            return(mv);
        }
示例#2
0
        /// <summary>
        /// 创建一个新视图
        /// </summary>
        /// <param name="viewpath">视图路径.注:不带文件后缀</param>
        /// <param name="model">数据模型,该值可为null</param>
        /// <remarks>注:该方法为一切视图的产生,如视图产生有相关变化,请重写该方法.</remarks>
        public virtual MvcView CreateView(string viewpath, object model)
        {
            string view = this.ViewRootPath + this.ViewGroupName;

            view += "/" + viewpath + ".ascx";
            MvcView mv = (MvcView)BuildManager.CreateInstanceFromVirtualPath(view, typeof(MvcView));

            mv.Model = model;
            return(mv);
        }