The document discusses different types of ASP.NET server controls including HTML server controls, web server controls, and validation controls. It also covers manipulating pages and controls with JavaScript, comparing postbacks to callbacks, and common control properties.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
32 views
2
The document discusses different types of ASP.NET server controls including HTML server controls, web server controls, and validation controls. It also covers manipulating pages and controls with JavaScript, comparing postbacks to callbacks, and common control properties.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8
CHAPTER 2
ASP.NET SERVER CONTROLS
Types of Server Control –HTML Server Controls (Traditional HTML tags) –Web Server Controls (New ASP. NET tags) –Validation Controls –User Define Controls ASP.NET SERVER CONTROLS (CONT..) HTML server controls – These controls are basically the original HTML controls but enhanced to enable server side processing. – To make these elements programmable, add a runat="server" attribute to the HTML element. This attribute indicates that the element should be treated as a server control. – All HTML server controls must be within a <form> tag with the runat="server" attribute. The runat="server" attribute indicates that the form should be processed on the server. – You have all the HtmlControl class’s properties and methods available such as, ID, EnableViewState, Disabled, Style, and some more. HTML SERVER CONTROLS (CONT..) HtmlControl Class – The HtmlControl base class is used for those HTML classes that are focused on HTML elements that can be contained within a single node. Such as <img>, <input>, and <link> elements. HtmlContainerControl Class – A class specifically designed to work with HTML elements that require a closing tag. – HTML elements such as <a>, <form>, and <select>, require an opening and closing set of tags. – These controls have some extra properties like InnerText and InnerHtml. – InnerHtml: Enables you to specify content that can include HTML elements to be placed between the opening and closing tags of the specified control. – InnerText: Enables you to specify raw text to be placed between the opening and closing tags of the specified control. HtmlGenericControl Class – Using the HtmlGenericControl class, you can get server-side access to the <meta>, <p>, <span>, or other elements that would otherwise be unreachable. MANIPULATING PAGES AND SERVER CONTROLS WITH JAVASCRIPT • Apply JavaScript directly to the controls on your ASPX page. • Using Page.ClientScript.RegisterClientScriptBlock – The RegisterClientScriptBlock method allows you to place a JavaScript function at the top of the page. – RegisterClientScriptBlock(type, key, script, script tag specification) MANIPULATING PAGES AND SERVER CONTROLS WITH JAVASCRIPT (CONT..) • Using Page.ClientScript.RegisterStartupScript – RegisterStartupScript places the script at the bottom of the ASP.NET page instead of at the top. – RegisterStartupScript(type, key, script, script tag specification) • Using Page.ClientScript.RegisterClientScriptInclude – You can register the script files on your ASP.NET pages using the RegisterClientScriptInclude method. – Page.ClientScript.RegisterClientScriptInclude(type, key, url) COMPARING A TYPICAL POSTBACK TO A CALLBACK • Postback – A postback occurs when a request is sent from the client to the server for the same page as the one the user is currently viewing. – When a postback occurs, the entire page is refreshed. •Callback – A callback occurs when a request is sent from the client to the server for which the page is not refreshed. – Only a part of it is updated without any flickering occurring on the browser COMMON PROPERTIES • Access Key – Alt + key. • Attributes – Enables you to define additional attributes for a Web server control that are not defined by a public property.
• Disabled – Allows you to get or set whether the control is disabled using a Boolean value.
• Visible – Specifies whether the control is visible on the generated page.