1 / 31

第三章 Web 服务器控件

第三章 Web 服务器控件. 学习要点. Web 控件的属性和事件 web 控件分类 列表控件 控制控件 选择控件 广告控件 日历控件. WEB 控件简介. Web 控件源自 System.Web.UI.WebControls 名称空间,是由 WebControl 基础控件驱动的。 Web 控件具有更丰富且一致的对象模块, Web 控件有许多共同的属性,属性及方法名称有一致性,让用户不会因为不同的控件,有相同属性却又不同属性的名称而产生迷惑;

chaim
Télécharger la présentation

第三章 Web 服务器控件

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第三章Web服务器控件

  2. 学习要点 • Web控件的属性和事件 • web控件分类 • 列表控件 • 控制控件 • 选择控件 • 广告控件 • 日历控件 ASP.NET教程 张奎 2006

  3. ASP.NET教程 张奎 2006

  4. WEB控件简介 • Web控件源自System.Web.UI.WebControls名称空间,是由WebControl基础控件驱动的。 • Web控件具有更丰富且一致的对象模块,Web控件有许多共同的属性,属性及方法名称有一致性,让用户不会因为不同的控件,有相同属性却又不同属性的名称而产生迷惑; • 同时Web控件可以自动检查浏览器的类型、提供数据链接以及可以直接套用用户设计的模板等功能,可以说,Web控件是ASP.NET强大功能的体现。 ASP.NET教程 张奎 2006

  5. Web控件属性-1 • AccessKey 属性 • 这个属性可以用来指定键盘的快速键。我们可以指定这个属性的内容为数字或是英文字母,当使用者按下键盘上的「Alt」再加上我们所指定的值时,表示选择该控件。例如控件Button 的AccessKey 属性为「A」,当使用者按下「Alt」+「A」时即表示按下了按钮: ❑ BackColor: The background color of the control; for example, AliceBlue, AntiqueWhite, or even a hexadecimal value like #C8C8C8. ❑ ForeColor: The foreground color of the control. ❑ BorderWidth: The width of the border of the control, in units of either exs, ems, pixels, points,picas, inches, centimeters (or millimeters), or a percentage value. ❑ Visible: If set to True (the default for all controls) the control will be displayed ASP.NET教程 张奎 2006

  6. Web控件属性-2 ❑ Enabled: Whether on not the control is enabled. If set to False, the control will appear grayed out, and will not process or respond to events until its Enabled property is set to True. ❑ Height: The height of the control. ❑ Width: The width of the control. ❑ ToolTip: Hover text displayed dynamically on mouse rollover. Typically used to supply additional help without taking up space on the form. ❑ Font-Size: Size of the control's font. ASP.NET教程 张奎 2006

  7. Web控件属性举例 <asp:Button id="MyButton" runat="server" Text="I'm an ASP.NET server control Button!" BackColor="purple" ForeColor="white" BorderWidth="4" BorderStyle="Ridge" ToolTip="Common Properties Example!" Font-Name="Tahoma" Font-Size="16" Font-Bold="True" /> ASP.NET教程 张奎 2006

  8. web控件的事件驱动机制 • Web控件是对象 • 与对象一样,web控件拥有方法和属性,并且响应事件 • 一旦将web控件包括在web页中,就可以设置其属性并调用其方法 • 可以为web控件编写服务器端代码以响应在客户端上发生的事件 ASP.NET教程 张奎 2006

  9. 对象-模型输出效果 ASP.NET教程 张奎 2006

  10. Web控件分类 ASP.NET教程 张奎 2006

  11. Web控件-内部控件 • ASP.NET引入一组称为“内部控件”的新控件,它们专门用于ASP.NET • 内部控件的使用方法与HTML控件相同,它们映射到HTML元素并通过使用runat=“server”属性在服务器上执行 ASP.NET教程 张奎 2006

  12. Web控件-列表控件 • 这些控件用于在web页中创建数据列表 • 填充这些控件的数据通常是从数据库中检索的 • 用户可以了列表中选择一种选项,并且该选项将存储在数据库中 • 通常使用的标准表控件是repeater、DataList和DataGrid控件 ASP.NET教程 张奎 2006

  13. Web控件-复杂控件 当希望控件拥有复杂的功能或使用HTML元素无法创建的功能丰富的用户界面时,可以使用复杂控件 • 日历web控件可以创建一个日历 • 用户可以从中选择当前、以前和将来的某个月份和日期 • 用户无需输入不同的日期,只需使用同一日历控件来选择日期即可 ASP.NET教程 张奎 2006

  14. Web控件-验证控件 • 输入控件的数据需要进行准确性和取值范围方面的检查 • 在ASP中,验证工作只能使用客户端脚本语言在客户端上执行 • ASP.NET引入智能验证控件事验证工作在服务器端执行 ASP.NET教程 张奎 2006

  15. 内部控件 ASP.NET教程 张奎 2006

  16. 内部控件.Label控件 • 用于在页面上显示信息,是最常用的控件之一。 • The <asp:label> Control Attributes ❑ Text: Sets the text that you want the label to display. ❑ Visible: Sets whether the label control is currently visible on the page (true or false). ❑ BackColor: Sets the background color of the label. ❑ ForeColor: Sets the foreground color of the label. ❑ Height: Sets the height in pixels of the label. ❑ Width: Sets the width of the label control ASP.NET教程 张奎 2006

  17. 内部控件.文本输入 ASP.NET教程 张奎 2006

  18. 内部控件.控制转移 ASP.NET教程 张奎 2006

  19. 控制转移控件之间的差异 • Button和ImageButton用与将数据传递回服务器 • 当用户需要在页面之间导航时,主要使用Hyperlink • 尽管linkButton看起来像浏览器上的超链接,但是在单击时,它们呢会将数据传递回服务器 ASP.NET教程 张奎 2006

  20. 内部控件.选择 ASP.NET教程 张奎 2006

  21. Checkboxlist 和optionlist • 可使用循环 Items.controls.count Items[i].selected Selecteditemindex 和集合绑定 和数据库绑定 ASP.NET教程 张奎 2006

  22. 内部控机-选择-填充数据的方法 ASP.NET教程 张奎 2006

  23. 容器 ASP.NET教程 张奎 2006

  24. 内部控件.Table控件 Table控件用于创建HTML表格。Table的内容可以是静态的,但多数情况下Table的内容来自于数据库。TableRow就是表格中的行,用于控制整行的属性。TableCell控件是表格中的单元格,具体控制着每个单元格显示的内容。 ASP.NET教程 张奎 2006

  25. 复杂控件 ASP.NET教程 张奎 2006

  26. 广告科技的xml文档格式 ASP.NET教程 张奎 2006

  27. 广告的xml文档实例 ASP.NET教程 张奎 2006

  28. AdRotator-输出结果 ASP.NET教程 张奎 2006

  29. 日历控件事件 ASP.NET教程 张奎 2006

  30. 总结 • 内部控件 • 列表控件 • 复杂控件 • 验证控件 • 与对象一样,web控件拥有方法和属性,并且响应事件 ASP.NET教程 张奎 2006

  31. 作业 • 设置web控件的各种属性 • 编写一个简单的广告,利用日历控件读取和设定日期值 • 写一个列表控件,用三种不同的方式和数据绑定 ASP.NET教程 张奎 2006

More Related