选择显示字体大小

asp.net2.0+sql server2005构建多层应用(4)

  创建逻辑层

  接下来,我们创建逻辑层,在这个例子中,逻辑层是十分简单的,只是起到说明作用。首先,我们新建一个类authrobiz类,并将其放在app_code文件夹中,并将类的代码修改如下:

public class authorsbiz
{
 public authorsbiz()
 {}

 public datatable getauthors()
 {
  authorstableadapters.authorstableadapter authordb = new authorstableadapters.authorstableadapter();
  return authordb.getauthors();
 }
 public datatable getauthortitles(string authorid)
 {
  authorstableadapters.authortitlestableadapter authordb = new authorstableadapters.authortitlestableadapter();
  return authordb.gettitlesbyauthor(authorid);
 }
}

  从上面的代码中,可以看到,我们刚才通过向导创建的"authors.xsd"类型化dataset类,现在在代码中,可以通过使用authorstableadapters类来调用,其中authordb是authorstableadapters类的实例。

  创建表示层

  在asp.net 2.0中,在创建表示层时,可以使用master-page技术,使得可以很方便地构建页面。mater-page的意思是,可以首先构建出一个页面的主框架模版结构,然后在其中放置一个contentplaceholder控件,在该控件中,将展现其他子页面的内容。在其他子页面中,只需要首先引用该master页面,然后再修改contentplaceholder控件的内容就可以了。

  首先,在工程中新增加一个"master"类型的文件,将其命名为commonmaster,然后输入以下代码:

<%@ master language="c#" %>
html
 <head id="head1" runat="server">
  <title>master page</title>
 </head>
<body>
<form id="form1" runat="server">
 <table id="header" style="width: 100%; height: 80px" cellspacing="1" cellpadding="1" border="1">
 <tr>
  <td style="text-align: center; width: 100%; height: 74px;" bgcolor="teal">
   <asp:label runat="server" id="header" font-size="12pt" font-bold="true">
     authors information
   </asp:label>
  </td>
 </tr>
 </table>
 <b/>
 <table id="leftnav" style="width: 108px; height: 100%" cellspacing="1" cellpadding="1" border="1">
 <tr>
  <td style="width: 100px">
   <table>
    <tr>
     <td>
      <a href="home.aspx">home</a>
     </td>
    </tr>
    <tr>
     <td>
      <a href="authors.aspx">authors list</a>
     </td>
    </tr>
   </table>
  </td>
 </tr>
 </table>
 <table id="mainbody" style="left: 120px; vertical-align: top; width: 848px; position: absolute; top: 94px; height: 100%" border="1">
  <tr>
   <td width="100%" style="vertical-align: top">
    <asp:contentplaceholder id="middlecontent" runat="server"></asp:contentplaceholder>
   </td>
  </tr>
 </table>
</form>
</body>
</html

  接下来,我们首先创建以显示作者页面的authors.aspx页面,由于页面的框架要保持一直,因此,可以利用maser-page技术,在新建页面时,引入刚才建立的commonmaster页面,如下图:

′??web/asp/2005-10/23/05102320580662166.gif" onload="javascript:if(this.width>550)this.width=550" border=1>


  点add按钮后,出现如下图,选择刚才建立的commonmaster页面,如下图:

′??web/asp/2005-10/23/05102320580676821.gif" onload="javascript:if(this.width>550)this.width=550" border=1>


  再输入如下代码:

<%@ page language="c#" masterpagefile="~/commonmaster.master" %>
asp:content id="content1" contentplaceholderid="middlecontent" runat="server">
asp:objectdatasource runat="server" id="authorssource" typename="authorsbiz" selectmethod="getauthors">


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons