예제 #1
0
        private void RenderViewUserControl(ViewContext context, ViewUserControl control) {
            if (!String.IsNullOrEmpty(MasterPath)) {
                throw new InvalidOperationException(MvcResources.WebFormViewEngine_UserControlCannotHaveMaster);
            }

            control.ViewData = context.ViewData;
            control.RenderView(context);
        }
예제 #2
0
        private void RenderViewUserControl(ViewContext context, ViewUserControl control) {
            if (!String.IsNullOrEmpty(MasterPath)) {
                throw new InvalidOperationException();
            }

            control.ViewData = context.ViewData;
            control.RenderView(context);
        }
        public static string RenderViewUserControl(this HtmlHelper html, ViewUserControl control, object model) {
            ViewPage viewPage = new ViewPage();
            viewPage.ViewContext = html.ViewContext;
            viewPage.Controls.Add(control);
            viewPage.Url = new UrlHelper(html.ViewContext);
            viewPage.Html = new HtmlHelper(html.ViewContext, viewPage);

            control.ViewData = new ViewDataDictionary(html.ViewContext.ViewData);
            control.ViewData.Model = model;
            control.InitializeAsUserControl(viewPage);

            StringBuilder sb = new StringBuilder();
            StringWriter writer = new StringWriter(sb, CultureInfo.CurrentCulture);
            HttpContext.Current.Server.Execute(viewPage, writer, true);
            return sb.ToString();
        }
예제 #4
0
파일: WebFormView.cs 프로젝트: mdae/MonoRT
        public virtual void Render(ViewContext viewContext, TextWriter writer)
        {
            if (viewContext == null)
            {
                throw new ArgumentNullException("viewContext");
            }

            object viewInstance = BuildManager.CreateInstanceFromVirtualPath(ViewPath, typeof(object));

            if (viewInstance == null)
            {
                throw new InvalidOperationException(
                          String.Format(
                              CultureInfo.CurrentUICulture,
                              MvcResources.WebFormViewEngine_ViewCouldNotBeCreated,
                              ViewPath));
            }

            ViewPage viewPage = viewInstance as ViewPage;

            if (viewPage != null)
            {
                RenderViewPage(viewContext, viewPage);
                return;
            }

            ViewUserControl viewUserControl = viewInstance as ViewUserControl;

            if (viewUserControl != null)
            {
                RenderViewUserControl(viewContext, viewUserControl);
                return;
            }

            throw new InvalidOperationException(
                      String.Format(
                          CultureInfo.CurrentUICulture,
                          MvcResources.WebFormViewEngine_WrongViewBase,
                          ViewPath));
        }
예제 #5
0
        protected override void RenderView(ViewContext viewContext, TextWriter writer, object instance)
        {
            ViewPage viewPage = instance as ViewPage;

            if (viewPage != null)
            {
                RenderViewPage(viewContext, viewPage);
                return;
            }

            ViewUserControl viewUserControl = instance as ViewUserControl;

            if (viewUserControl != null)
            {
                RenderViewUserControl(viewContext, viewUserControl);
                return;
            }

            throw new InvalidOperationException(
                      String.Format(
                          CultureInfo.CurrentCulture,
                          MvcResources.WebFormViewEngine_WrongViewBase,
                          ViewPath));
        }
 public ViewUserControlContainerPage(ViewUserControl userControl)
 {
     _userControl = userControl;
 }
예제 #7
0
 public ViewUserControlContainerPage(ViewUserControl userControl)
 {
     Controls.Add(userControl);
 }
예제 #8
0
 /// <summary>
 /// Appends the current request's query string and form values to the object's values as a <see cref="RouteValueDictionary"/>.
 /// </summary>
 /// <param name="userControl"></param>
 /// <param name="routeValues"></param>
 /// <param name="excludeProperties"></param>
 /// <returns></returns>
 public static RouteValueDictionary MergeRequestValues(this ViewUserControl userControl, object routeValues, params string[] excludeProperties)
 {
     return(RouteValueHelper.MergeRequestValues(routeValues, userControl.Request, excludeProperties));
 }
예제 #9
0
 /// <summary>
 /// Appends the current request's query string values to the object's values as a <see cref="RouteValueDictionary"/>.
 /// </summary>
 /// <param name="userControl">Current user control.</param>
 /// <param name="routeValues">Object values to which the query string values will be combined.</param>
 /// <param name="excludeProperties">List of properties to exclude from combining.</param>
 /// <returns></returns>
 public static RouteValueDictionary MergeQSValues(this ViewUserControl userControl, object routeValues, params string[] excludeProperties)
 {
     return(RouteValueHelper.Combine(routeValues, excludeProperties, userControl.Request.QueryString));
 }
예제 #10
0
 public static string GetReturnUrl(this ViewUserControl pg)
 {
     return(GetReturnUrl(pg.Page as ViewPage));
 }
예제 #11
0
        public static string SiteRoot(this ViewUserControl pg)
        {
            var vpage = pg.Page as ViewPage;

            return(SiteRoot(vpage.ViewContext.HttpContext));
        }
예제 #12
0
 public static string GetReturnUrl(this ViewUserControl pg)
 {
     return(GetReturnUrl(pg.ViewContext.HttpContext));
 }