因维护OA而开启的ASP.NET之旅 —— 2. 划水练习

本文深入探讨ASP.NET服务器控件,包括Web控件、HTML服务器构件、客户端脚本JavaScript和验证控件。介绍了各种控件的属性、用法,如TextBox、Button、DropDownList等,并讲解了验证机制和用户控件的应用。
摘要由CSDN通过智能技术生成

ASP.NET服务器控件

  • 服务器控件的公共属性
    • AccessKey : Alt + key
    • Attributes
    • BackColor
    • BorderColor
    • BorderWidth
    • BoderStyle
    • ClientIDMode, INamingContainer
      • 控制控件Id的生产方式
        • AutoID
        • Inherit : 默认值
        • Predictable
        • Static : 开发人员指定
      • 可以通过machine.config/ web.config文件中的设置ClientID属性
    • CssClass
    • Enabled
    • EnableTheming
    • EnableViewState
    • Font
    • ForeColor
    • Height
    • SkinID
    • Style
    • TabIndex
    • ToolTip
    • Width

Web控件

    Web服务器控件是用于服务器的,而不是客户端。以asp:开头, ID, runat="server"
  • Label

  • Literal

    • Mode属性:如何解释控件的文本。 Encode, Transform, PassThrough
  • TextBox

    • TextMode:Password, MultiLine,
    • Wrap:True/False
    • Focus()
    • AutoPostBack
      • 浏览器必须支持ECMAScript
    • AutoCompleteType
      • 自动填充
      • Disabled, Company, HomeFax, Business …
  • Button

    • CausesValidation
    • CommandName
      • 多个按钮的OnCommand指向同一个事件时,用来区分不同Button
      • CommandArgument: 可用来传递参数
    • 使用客户端JavaScript
      • OnClientClick指向客户端函数
      • PostBackUrl:进行跨页面传送
  • LinkButton

  • ImageButton

  • HyperLink

    • NavigateUrl
    • ImageUrl 与 Text 相斥
  • DropDownList

    • 支持各种数据绑定
        1. .DataSource
        1. .DataBind()
    • AutoPostBack: 选中后触发OnSelectedIndexChanged事件
  • 从集合中可视化地删除数据项 : Value, Text

    • DropDownList
    • ListBox
      • SelectionMode: Single, Multiple
    • CheckBoxList
      • DataSourceID: SqlDataSource控件的ID
      • DataTextField: 显示字段
      • RepeatColumns: 指定使用多少列来显示结果
      • RepeatDirection: 布置方式, Vertial, Horizontal
    • RadioButtonList
      • Selected
    • BulletedList
      • BulletStyle: Nubmered, LowerAlpha, UpperAlpha, LowerRoman, UpperRomman, Disc, Circle, Square, NotSet, CustomImage
      • FirstBulletNumber
      • BulletImageUrl
      • DisplayMode : Text, HyperLink, LinkButton
  • CheckBox

    • IsChecked
    • Checked
    • TextAlgin
  • RadioButton

    • GroupName
  • Image

    • ImageUrl
    • DescriptionUrl : 指向包含图像描述的文件
  • Table

    • TableRow
    • TableCell
    • Captation : 标题
    • CaptionAlign
    • TableHeaderRow
    • TableFooterRow
  • Calendar

    • ToData Output Format
    • SelectionMode : Day, DayWeek, DayWeekMonth, None
    • SelectedDates
    • SelectedDayStyle
    • SomeDayStyle
    • DayRenderEventArgs
      • Day
      • Cell: 单元格对齐属性
  • AdRotator

    • AdvertisementFile=“Standard XML File
      • ImageUrl
      • NavigationUrl
      • AlternateText
      • Impression
      • KeyWord
    • DataSourceId
      • AlternateTextField
      • XXXXField
  • Xml

    • DocumentSource :指向xml文件的路径
    • TransformSource: 提供了在转换xml文档时使用的XSLT文件
  • Panel

    • ScrollBars : Auto, None, Horizontal, Vertial, Both
    • HorizontalAlign : NotSet, Center, Justify, Left, Right
    • Direction : NotSet, LeftToRight, RightToLeft
  • PlaceHolder : 占位符控件

  • HiddenField

  • FileUpload

    • web.config
      • maxRequestLength : 文件请求大小 KB
      • executionTimeout : 请求超时时长
      • 须在<system.web>内
  • MultiView / View

    • ActiveViewIndex
  • Wizard

    • WizardStep
    • 定制边栏导航
    • AllowReturn
    • StepType : Auto, Start, Step, Finish, Complete
    • HeaderText
    • DisplayCancelButton
    • CancelButtonType
    • FinishButtonType
    • FinishStepPrevioutButtonType
    • NextStepButtonType
    • PreviousStepButton
    • StartStepNextButtonType
    • CancelDestinationPageUrl
    • FinishDestinationPageUrl
    • XXXXButtonText
    • ActiveStepChanged
    • CancelButtonClick
    • FinishButtonClick
    • NextButtonClick
    • PreviousButtonClick
    • SideBarButtonClick
  • ImageMap 把图像转变为导航菜单

    • XXXXHotSpot
      • PostBackValue
      • NavigateUrl
    • HotSpotMode : PostBack, Navigate, InActive

HTML服务器构件

  • 标准的HTML + Runat=“server”

    • 派生自 HtmlControl

      • Attributes
      • Disabled
      • EnablingTheming
      • EnableViewState
      • ID
      • Page
      • Parent
      • Site
      • SkinID
      • Style
      • TagName
      • Visible
  • HTML类

    • HtmlAnchor
    • HtmlArea
    • HtmlAudio
    • HtmlButton
    • HtmlForm
    • HtmlHead
    • HtmlIFrame
    • HtmlImage
    • HtmlInputButton
    • HtmlInputCheckBox
    • HtmlInputFile
    • HtmlInputHidden
    • HtmlInputImage
    • HtmlInputPassword
    • HtmlInputRadioButton
    • HtmlInputReset
    • HtmlInputSubmit
    • HtmlInputText
    • HtmlLink
    • HtmlMeta
    • HtmlSelect
    • HtmlSource
    • HtmlTable
    • HtmlTableCell
    • HtmlTableRow
    • HtmlTextArea
    • HtmlTitle
    • HtmlTrack
    • HtmlVideo
  • HtmlGenericControl类

    • 可以访问 meta, p, span 或其它元素
    • id , runat

客户端脚本 javascript

  • JavaScript直接应用于控件
  • Page.ClientScript
    • 在ASP.NET页面上注册和使用JavaScript函数库
    • .RegisterClientScriptBlock 生成js在
    • .RegisterStartupScript 生成js在页面尾部
    • .RegisterClientScriptInclude 生成js在单独.js文件

验证控件

  • 验证控件

    • RequiredFieldValidator : 用户输入

      • Text
        • <img>
        • <audio>
      • ErrorMessage
      • ControlToValidate
        • DropDownList, FileUpoad, ListBox, RadioButtonList, TextBox
        • HtmlInputFile, HtmlInputPassword, HtmlInputText, HtmlSelect, HtmlTextArea
      • EnableClientScript
      • InitiaValue
        • 非空检验需要额外使用一个RequiredFieldValidatr
      • ValidationGroup
      • SetFocusOnError
    • CompareValidator : 允许使用比较运算符比较用户输入

      • ControlToCompare
      • Type : Currency, Date, Double, Integer, String
      • Operator : Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, DataTypeCheck
      • ValueToCompare
    • RangeValidator : 数字范围或字母范围

      • MaxmiumValue, MinimumValue
    • RegularExressionValidator : 正则表达式匹配

      • ValidationExpression
    • CustomValidator : 用户自定义验证逻辑检查输入

      • ClientValidationFunction: javascript function Name
      • OnServerValidate
    • DynamicValidator : 在处理实体数据模型和法抛出异常时使用

    • ValidationSummary : 在页面某个位置显示验证控件的所有错误消息

      • DisplayMode : BulletList, List, SingleParagraph
      • ShowMessageBox : 以消息框显示错误消息
      • ShowSummary : 显示验证错误消息
    • 第三方验证控件

      • http://www.peterblum.com/DES
  • CauseValidation : True 启动验证

  • Page.IsValid

  • Control ValidationGroup

  • 隐含验证

    • web.config
      • ValidationSettings:UnobtrusiveValidationModel : None, WebForms
      • WebForms 启用隐含验证模式
    • global.asax Application_Start
      • ValidationSetting.UnobtrusiveValidationModel = .None / .WebForms
    • Page_Load
      • Page.UnobtrusiveValidationModel = .None / .WebForms
    • 使用 ASP.NET Ajax ScriptManager 注册 jQuery JavaScript库
      • jQuery , AspNet.ScriptManger.jQuery

用户控件

  • 业务对象

  • .NET 是面向对象的架构

  • UserContrl .ascx

    • <%@ Control %>
    • Init, Load, Prerender
    • Page.LoadControl
      • Controls.Add
      • ViewState
    • PartialCachingControl
    • Session
  • @Reference

  • UI.WebControls.WebControl

    • 拥有参与页面架构所需的基本功能
    • ASP.NET Server Control
  • UI.ScriptControl

  • 在WebControl基础上,添加了ScriptManager支持功能

  • ASP.NET AJAX Server Control

  • 控件特性

    • 类特性
      • Designer
      • TypeConverter
      • DefaultEvent
      • DefaultProperty
      • ControlBuilder
      • ParseChildren
      • TagPrefix
    • 属性事件特性
      • Bindable
      • Browsable
      • Category
      • Description
      • EditorBrowsable
      • DefaultValue
      • DesignerSerializationVisibility
      • NotifyParentProperty
      • PersistChildren
      • PersistanceMode
      • TemplateContainer
      • Editor
      • Localizable
      • Themable
  • 控件生命周期

  • 显示HTML标记

    • RenderContents
      • HtmlTextWriter
        • RenderBeginTag
        • WriteBeginTag
        • RenderEndTag
        • AddAttribute
        • AddAttributeToRender
        • AddStyleAttribute
  • 添加客户端功能

    • ClientScriptManaer
      • Page.ClientScript
        • RegisterStartupScript
        • RegisterClientScriptBlock
        • RegisterClientSriptInclude
        • RegisterClientScriptResource
    • System.Web.UI.IcallbackEventHandler
      • RaiseCallbackEvent
      • GetCallBackResult
      • Page.GetCallbackEventReference
    • .browser
      • Syste.Web.HttpBrowserCapabilities
        • Page.Request.Browser
    • ViewState
      • 支持类型
        • 基本类型
        • 基本类型数组
        • ArrayList, HashTable
        • Pair, Triplet
        • Color, DateTime
        • String, IndexedString
        • HybridDictionary
        • TypeConverter
        • [Serializable]
      • ControlState
        • SaveControlState()
        • LoadControlState()
          • Page.RegisterRequiresControlState
    • 回送
      • IPostbackDataHandler
        • LoadPostData
        • RaisePostBackDataChangeEvent
      • IPostbackEventHandler
      • GetPostBackEventReference
        • PostBackOptions
  • CompsiteControl

  • 模板化控件

  • 服务器控件

    • 类型转换器
      • 特性TypeConverter
      • 定制TypeConverter
    • 设计器
      • 特性Designer

      • 定制ControlDesigner

        • CompositeControlDesigner
        • TemplateControlDesigner
        • DataSourceDesigner
      • DesignerActionResultItem

    • UI类型编辑器
      • 特性Editor
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值