.Text 页面分析


<DT:MASTERPAGE id="MPContainer" runat="server">
    <DT:contentregion id="MPMain" runat="server">
     <asp:PlaceHolder id="CenterBodyControl" runat="server"></asp:PlaceHolder>
    </DT:contentregion>
   </DT:MASTERPAGE>
控件<DT:MASTERPAGE id="MPContainer" runat="server"> 负责装载Template.ascx文件;
控件<DT:contentregion id="MPMain" runat="server">用于在Template.ascx控件中定位,其中<DT:contentregion id="MPMain" runat="server">的控件名字必须与
Template.ascx中的一个控件名字相对应。由此就实现了Default.aspx中的特定控件在Template.ascx中的定位。
假若有多个contentregion控件,在template.ascx中也要有多个相对应名字的控件
不过在default.aspx中的contentregion要是平行级别,不是牵套。
在页面类Dottext.Web.UI.Pages.DottextMasterPage中,实现了向<asp:PlaceHolder id="CenterBodyControl" runat="server"></asp:PlaceHolder>控件加载控件的
功能。而加载的控件都是从配置文件里通过url重写根据url的不同而读取的

附:
 default.aspx

 <%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false" Inherits="Dottext.Web.UI.Pages.DottextMasterPage"%>
<%@ Register TagPrefix="DT" Namespace="Dottext.Web.UI.WebControls" Assembly="Dottext.Web" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title><asp:Literal ID="pageTitle" Runat="server" /></title>
  <meta content=".Text" name="GENERATOR">
  <link id="MainStyle" type="text/css" rel="stylesheet" runat="Server"/>
  <link id="SecondaryCss" type="text/css" rel="stylesheet" runat="Server"/>
  <link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" runat="Server"/>
 </HEAD>
 <body>
  <form id="Form1" method="post" runat="server">
   <DT:MASTERPAGE id="MPContainer" runat="server">
    <DT:contentregion id="MPMain" runat="server">
     <asp:PlaceHolder id="CenterBodyControl" runat="server"></asp:PlaceHolder>
    </DT:contentregion>
   </DT:MASTERPAGE></form>
 </body>
</HTML>

 Template.ascx

<%@ Register TagPrefix="uc1" TagName="Footer" Src="Footer.ascx" %>
<%@ Register TagPrefix="uc1" TagName="SiteCategory" Src="SiteCategory.ascx" %>
<%@ Register TagPrefix="uc1" TagName="PostsList" Src="PostsList.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="SiteSearch" Src="SiteSearch.ascx" %>
<%@ Register TagPrefix="uc1" TagName="PagedPosts" Src="PagedPosts.ascx" %>
<%@ Register TagPrefix="uc1" TagName="SiteNavigate" Src="SiteNavigate.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Syndication" Src="~/AggSite/Syndication.ascx" %>
<%@ Register TagPrefix="uc1" TagName="AggStats" Src="~/AggSite/AggStats.ascx" %>
<%@ Register TagPrefix="uc1" TagName="BlogList" Src="~/AggSite/BlogList.ascx" %>
<%@ Register TagPrefix="DT" Namespace="Dottext.Web.UI.WebControls" Assembly="Dottext.Web" %>
<%@ Register TagPrefix="uc1" TagName="FriendLink" Src="FriendLink.ascx" %>
<uc1:header id="Header1" runat="server"></uc1:header>
<div id="authors"><DT:CONTENTREGION id="LeftColumn" runat="server">
  <uc1:SiteNavigate id="SiteNavigate1" runat="server"></uc1:SiteNavigate>
  <uc1:SiteCategory id="SiteCategory1" runat="server"></uc1:SiteCategory>
  <uc1:SiteSearch id="SiteSearch1" runat="server"></uc1:SiteSearch>
  <uc1:Syndication id="Syndication1" runat="server"></uc1:Syndication>
  <uc1:AggStats id="AggStats1" runat="server"></uc1:AggStats>
  <uc1:FriendLink id="FriendLink1" runat="server"></uc1:FriendLink>
  <uc1:BlogList id="BlogList1" title="博客排行榜" runat="server"></uc1:BlogList>
 </DT:CONTENTREGION></div>
<div id="main"><DT:CONTENTREGION id="MPMain" runat="server"></DT:CONTENTREGION></div>
<div id="footer"><uc1:Footer id="Footer1" runat="server"></uc1:Footer></div>

PagePosts.ascx  (Dottext.Web.UI.Pages.DottextMasterPage中加载的控件)

 <%@ OutputCache Duration="60" VaryByParam="page;date;cate;onlytitle;cateid;group;id;author" VaryByCustom="Url" %>
<%@ Register TagPrefix="dt" Namespace="Dottext.Web.UI.WebControls" Assembly="Dottext.Web"%>
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="PagedPosts.ascx.cs" Inherits="Dottext.Web.AggSite.PagedPosts" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<h2><asp:literal id="CatalogTitle" runat="server"></asp:literal></h2>
<dt:pager id="ResultsPager" runat="server" CssClass="Pager" LinkFormatActive="{1}" UseSpacer="True"
 DisplayMode="Block"></dt:pager>
<asp:repeater id="RecentPostsRepeater" runat="server">
 <ItemTemplate>
  <div class="post">
   <h3>
    <asp:HyperLink Runat = "server" NavigateUrl = '<%# BuildUrl(DataBinder.Eval(((RepeaterItem)Container).DataItem,"TitleUrl",null),DataBinder.Eval(((RepeaterItem)Container).DataItem,"Link",null),DataBinder.Eval(((RepeaterItem)Container).DataItem,"SourceUrl").ToString(),DataBinder.Eval(((RepeaterItem)Container).DataItem,"PostType").ToString()) %>' Text = '<%# DataBinder.Eval(((RepeaterItem)Container).DataItem,"Title") %>' ID="lnkTitle"/>
   </h3>
   <h4>
    <asp:Literal runat = "server" Text = '<%# CheckLength(DataBinder.Eval(((RepeaterItem)Container).DataItem,"Body").ToString()) %>' ID="BlogContentLabel" />
   </h4>
   <p class="postfoot" align="right">
    <asp:Literal runat = "server" Text = '<%# (DateTime.Parse(DataBinder.Eval(((RepeaterItem)Container).DataItem,"DateCreated",null))).ToString("yyyy-MM-dd HH:mm") %>' ID="Label5"/>
    作者:
    <asp:HyperLink Runat = "server" CssClass = "clsSubText" NavigateUrl='<%# GetBlogUrl() %>' Text = '<%# DataBinder.Eval(((RepeaterItem)Container).DataItem,"Author",null) %>' ID="Hyperlink3"/>
    <asp:HyperLink runat = "server" CssClass = "CommentLink" NavigateUrl='<%# GetUrl()+"#Post" %>' Text = '<%# "【评论:"+DataBinder.Eval(((RepeaterItem)Container).DataItem,"FeedBackCount")+"】" %>' ID="lnkComments"/>【阅读:
    <asp:Literal runat = "server" Text = '<%# DataBinder.Eval(((RepeaterItem)Container).DataItem,"ViewCount") %>' ID="Literal2"/>】
   </p>
  </div>
 </ItemTemplate>
</asp:repeater>
<h6><dt:pager id="ResultsPager2" runat="server" CssClass="Pager" LinkFormatActive="{1}" UseSpacer="True"></dt:pager></h6>


东方文学网

 
using System; using System.Data; using System.Windows.Forms; using Rept.BLL; using ReptEnergy.Public; using Rept.Model; using DevExpress.XtraEditors; using System.Collections.Generic; namespace ReptEnergy { public partial class FrmPort : Form { private ApiConfiguration apiConfigureation; public FrmPort() { InitializeComponent(); } #region 页面初始化 private void FrmPort_Load(object sender, EventArgs e) { QueryApi(); } #endregion #region 查询 private void QueryApi() { DataTable apiTable = apiConfigureation.Query(); if (apiTable == null || apiTable.Rows.Count == 0) { return; } foreach (DataRow dr in apiTable.Rows) { if (dr["AppConfigName"].Equals("WebServiceURL")) { teUrl.Text = dr["AppConfigValue"].ToString(); } if (dr["AppConfigName"].Equals("HeadInfo")) { teUrl.Text = dr["AppConfigValue"].ToString(); } if (dr["AppConfigName"].Equals("Wind")) { teUrl.Text = dr["AppConfigValue"].ToString(); } if (dr["AppConfigName"].Equals("Materialloading")) { teUrl.Text = dr["AppConfigValue"].ToString(); } if (dr["AppConfigName"].Equals("EquipStatus")) { teUrl.Text = dr["AppConfigValue"].ToString(); } if (dr["AppConfigName"].Equals("EquipAlarm")) { teUrl.Text = dr["AppConfigValue"].ToString(); } if (dr["AppConfigName"].Equals("OperationCheck")) { teUrl.Text = dr["AppConfigValue"].ToString(); } } } #endregion #region 保存 private void btnSave_Click(object sender, EventArgs e) { List<Basappconfig> cfList = new List<Basappconfig>(); Basappconfig cfModel; #region 判断页面值 if (string.IsNullOrEmpty(teUrl.Text)) { XtraMessageBox.Show("URL值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcUrl.Text.Trim(); cfModel.AppConfigValue = teUrl.Text.Trim(); cfList.Add(cfModel); } if (string.IsNullOrEmpty(teHeadInfo.Text)) { XtraMessageBox.Show("HeadInfo值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcHeadInfo.Text.Trim(); cfModel.AppConfigValue = teHeadInfo.Text.Trim(); cfList.Add(cfModel); } if (string.IsNullOrEmpty(teWind.Text)) { XtraMessageBox.Show("Wind值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcWind.Text.Trim(); cfModel.AppConfigValue = teWind.Text.Trim(); cfList.Add(cfModel); } if (string.IsNullOrEmpty(teMaterialloading.Text)) { XtraMessageBox.Show("Materialloading值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcMaterialloading.Text.Trim(); cfModel.AppConfigValue = teMaterialloading.Text.Trim(); cfList.Add(cfModel); } if (string.IsNullOrEmpty(teEquipStatus.Text)) { XtraMessageBox.Show("EquipStatus值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcEquipStatus.Text.Trim(); cfModel.AppConfigValue = teEquipStatus.Text.Trim(); cfList.Add(cfModel); } if (string.IsNullOrEmpty(teEquipAlarm.Text)) { XtraMessageBox.Show("EquipAlarm.值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcEquipAlarm.Text.Trim(); cfModel.AppConfigValue = teEquipAlarm.Text.Trim(); cfList.Add(cfModel); } if (string.IsNullOrEmpty(teOperationCheck.Text)) { XtraMessageBox.Show("OperationCheck值为空,请填写后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { cfModel = new Basappconfig(); cfModel.AppConfigName = lcOperationCheck.Text.Trim(); cfModel.AppConfigValue = teOperationCheck.Text.Trim(); cfList.Add(cfModel); } #endregion int result = 0; try { result = apiConfigureation.ApiSave(cfList); } catch (Exception ex) { CommonMethod cmd = new CommonMethod(); string str = cmd.GetExceptionMsg(ex.Message); XtraMessageBox.Show(str, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (result > 0) { XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); QueryApi(); return; } else { XtraMessageBox.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } #endregion } } 检查代码
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值