本文整理汇总了C#中WebPage类的典型用法代码示例。如果您正苦于以下问题:C# WebPage类的具体用法?C# WebPage怎么用?C# WebPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebPage类属于命名空间,在下文中一共展示了WebPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PiranhaHelper
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="html"></param>
public PiranhaHelper(WebPage parent, HtmlHelper html)
{
Parent = parent ;
Html = html ;
Gravatar = new GravatarHelper() ;
Culture = new CultureHelper() ;
}
示例2: TestWebPage
public void TestWebPage()
{
var page = new WebPage<MyPage>("http://ya.ru", "<html><html>")
{
FuncParse = () => new MyPage {Id = 1, Title = "Test page"}
};
Assert.AreEqual(new MyPage {Id = 1, Title = "Test page"}, page.Model);
}
示例3: Search
public void Search(string website, string regexPattern)
{
List<string> output = new List<string>();
_regexPattern = regexPattern;
webpage = new WebPage();
webpage.WebPageLoaded += WebPageLoadedSearchCalled;
webpage.Load(website);
}
示例4: ExtractList
/// <summary>
/// Extract from the web page and return the results as a list.
/// </summary>
/// <param name="page">The web page to extract from.</param>
/// <returns>The results of the extraction as a List.</returns>
public IList<Object> ExtractList(WebPage page)
{
Listeners.Clear();
var listener = new ListExtractListener();
AddListener(listener);
Extract(page);
return listener.List;
}
示例5: WebPageDecorator
/// <summary>
/// Initializes a new instance of the WebPageDecorator class
/// </summary>
/// <param name="webPage">The web page model.</param>
/// <param name="context">The data context.</param>
public WebPageDecorator(WebPage webPage, IDataContext context)
{
if (webPage is WebPageDecorator)
Model = ((WebPageDecorator)webPage).Model;
else
Model = webPage;
this.Context = context;
Model.CopyTo(this, new string[] { "Widgets", "Roles", "Scripts", "StyleSheets" });
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
webPage = this.Page as WebPage;
if (!IsPostBack)
{
ltlMenu.Text = webPage.SideMenus;
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (this.Page is WebPage)
{
webPage = (this.Page as WebPage);
}
else
{
webPage = new WebPage(1);
}
}
示例8: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
var page = new WebPage();
if (IsLoaded)
page.CopyPropertiesFrom(OriginalPage);
page.ParentPageId = null;
if (!String.IsNullOrEmpty(cboParentPages.SelectedValue))
page.ParentPageId = Convert.ToInt32(cboParentPages.SelectedValue);
page.Name = txtName.Text;
page.CompanyId = Company.CompanyId;
page.Description = txtDescription.Value.Replace("$0", "<br/>");
page.IsInMenu = chkIsInMenu.Checked;
page.IsPublished = chkIsPublished.Checked;
page.CanComment = chkCanComment.Checked;
page.MasterPage = cboMasterPage.Text;
if (page.IsPublished)
{
if (!page.PublishedDate.HasValue)
page.PublishedDate = DateTime.Now;
}
else
page.PublishedDate = null;
page.RedirectUrl = null;
if (!String.IsNullOrEmpty(txtRedirectUrl.Text))
page.RedirectUrl = txtRedirectUrl.Text;
page.ModifiedDate = DateTime.Now;
if (!page.UserId.HasValue)
page.UserId = User.Identity.UserId;
SiteManager.Save(page, txtTags.Text);
if (((WebControl)sender).ID == "btnSaveAndNew")
{
Response.Redirect("WebPage.aspx");
return;
}
//
//Close the modal popup and redirect for WebPages.aspx
//
ClientScript.RegisterStartupScript(this.GetType(), "close", "top.$.LightboxObject.close();", true);
//Response.Redirect("WebPages.aspx");
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (this.Page is WebPage)
{
webPage = (this.Page as WebPage);
}
else
{
webPage = new WebPage(1);
}
Page.Title = webPage.WebName;
ltlKeyword.Text = "<meta name=\"keywords\" content=\"" + webPage.Keywords + "\"/>";
ltlDescription.Text = "<meta name=\"description\" content=\"" + webPage.Description + "\"/>";
}
示例10: Main
static void Main(string[] args)
{
WebPage webInfo = new WebPage("http://zhan.renren.com/flipped2012/more?page=1&count=20");
//"http://zhan.renren.com/ranzhi12/more?page=1&count=20"
string context = webInfo.Context;
string html = webInfo.M_html;
List<Link> result = webInfo.Links;
IEnumerable<IGrouping<string,Link>> tmp = result.GroupBy(o => o.Tag);
//var tmp2 = result.Where(o => o.Tag == "img" & (o.Src.IndexOf("xlarge") > -1 || o.Src.IndexOf("original") > -1)).ToList();
var imgs = result.Where(o => o.Tag == "img").ToList();
}
示例11: RenderWebPage
public static string RenderWebPage(WebPage page, StartPage startPage = null) {
var writer = new StringWriter();
// Create an actual dummy HttpContext that has a request object
var filename = "default.aspx";
var url = "http://localhost/default.aspx";
var request = new HttpRequest(filename, url, null);
var httpContext = new HttpContext(request, new HttpResponse(new StringWriter(new StringBuilder())));
var pageContext = Util.CreatePageContext(httpContext);
page.ExecutePageHierarchy(pageContext, writer, startPage);
return writer.ToString();
}
示例12: RenderWebPage
public static string RenderWebPage(WebPage page, StartPage startPage = null, HttpRequestBase request = null)
{
var writer = new StringWriter();
// Create an actual dummy HttpContext that has a request object
var filename = "default.aspx";
var url = "http://localhost/default.aspx";
request = request ?? CreateTestRequest(filename, url).Object;
var httpContext = CreateTestContext(request);
var pageContext = new WebPageContext { HttpContext = httpContext.Object };
page.ExecutePageHierarchy(pageContext, writer, startPage);
return writer.ToString();
}
示例13: WebPageHttpHandler
public WebPageHttpHandler(string virtualPath)
{
// create a new WebPage instance for use when processing the request
this.Page = (WebPage)WebPageBase.CreateInstanceFromVirtualPath(virtualPath);
Func<WebPageRenderingBase> func = null;
if (func == null)
{
func = delegate
{
return StartPage.GetStartPage(this.Page, "_PageStart", System.Web.WebPages.WebPageHttpHandler.GetRegisteredExtensions());
};
}
this._startPage = new Lazy<WebPageRenderingBase>(func);
}
示例14: WebPageLoadedSearchCalled
private void WebPageLoadedSearchCalled(object sender, WebPage.WebPageArguments args)
{
string htmlData = webpage.htmlData;
if (htmlData != null)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(_regexPattern);
results = regex.Matches(htmlData);
}
if(InfoReady != null)
{
InfoReady(this, new InfoReadyEventArgs("info ready"));
}
// webpage.WebPageLoaded -= WebPageLoadedSearchCalled;
}
示例15: InjectContext
public static void InjectContext(WebPage razorWebPage, MacroModel macro, INode currentPage) {
var context = HttpContext.Current;
var contextWrapper = new HttpContextWrapper(context);
//inject http context - for request response
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Context (file: {0})", macro.Name));
razorWebPage.Context = contextWrapper;
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Context (file: {0})", macro.Name));
//Inject Macro Model And Parameters
if (razorWebPage is IMacroContext) {
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Boxing Macro Script MacroContext (file: {0})", macro.Name));
var razorMacro = (IMacroContext)razorWebPage;
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Boxing Macro Script MacroContext (file: {0})", macro.Name));
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Model (file: {0})", macro.Name));
razorMacro.SetMembers(macro, currentPage);
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Model (file: {0})", macro.Name));
}
}