forked from xuxiaowei007/FoxOne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPageController.cs
44 lines (43 loc) · 1.3 KB
/
PageController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using FoxOne.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using FoxOne.Core;
using FoxOne.Controls;
using FoxOne.Business.Environment;
namespace FoxOne.Web.Controllers
{
public class PageController : BaseController
{
public string Index(string pageId, string ctrlId)
{
var page = PageBuilder.BuildPage(pageId);
if (page == null)
{
throw new PageNotFoundException();
}
page.PreRender();
if (!ctrlId.IsNullOrEmpty())
{
var ctrl = page.FindControl(ctrlId) as IComponent;
if (ctrl == null)
{
throw new FoxOneException("Ctrl_Not_Found", ctrlId);
}
return ctrl.Render();
}
return page.Render();
}
public string PreView()
{
string pageId = Request.QueryString[NamingCenter.PARAM_PAGE_ID];
var page = PageBuilder.BuildPage(pageId);
page.RegisterStartUpScript("Design", "foxOne.design();");
page.PreRender();
return page.Render();
}
}
}