Select the product you need help with
Introduction to ASP.NET inline expressions in the .NET FrameworkArticle ID: 976112 - View products that this article applies to. On This PageINTRODUCTIONThis article contains an introduction to the following
ASP.NET inline expressions:
MORE INFORMATION<% ... %> embedded code blocksThe embedded code block is used to preserve backward compatibility with classical ASP. The code in the block can execute programming statements and call functions in the current page class during the page-rendering phase.The following example demonstrates an ASP.NET page that has sample Microsoft Visual Basic .NET code in an embedded code block to display the results of a loop: For more information about embedded code blocks in ASP.NET Web pages, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn.microsoft.com/en-us/library/ms178135.aspx
(http://msdn.microsoft.com/en-us/library/ms178135.aspx)
<%= ... %> displaying expressionThe <%= ... %>displaying expression is an equivalent of the embedded code block that contains only the Response.Write(…) statement. This is the simplest way to display information such as a single string, an int variable, or a constant.For example, the following sample code displays the current time: For more information about how to display information from ASP.NET, visit the following MSDN Web site: http://msdn.microsoft.com/en-us/library/6dwsdcf5.aspx
(http://msdn.microsoft.com/en-us/library/6dwsdcf5.aspx)
<%@ ... %> directive expressionThe directive expression is the syntax that specifies settings that are used by the page and by user control compilers when they process ASP.NET Web Form (.aspx) pages and User Control (.ascx) files.The ASP.NET page framework supports the following directives: Collapse this table
http://msdn.microsoft.com/en-us/library/xz702w3e.aspx
(http://msdn.microsoft.com/en-us/library/xz702w3e.aspx)
<%# ... %> data-binding expressionThe data-binding expression creates binding between a server control property and a data source when the control’s DataBind method of this server control is called on the page.The following example shows how to use the data-binding expression to bind the string from a function to the Text property of a label: http://msdn.microsoft.com/en-us/library/bda9bbfx.aspx
(http://msdn.microsoft.com/en-us/library/bda9bbfx.aspx)
<%$ ... %> expression builderThe expression builder is used to set values of control properties based on the information that is contained in an application's configuration or resource files. The following is the basic syntax of the expression builder:<%$ Expression Prefix: Expression Value %> The dollar sign ($) indicates to ASP.NET that the
following expression is an expression builder. The expression prefix defines
the kind of expression, such as AppSettings, ConnectionStrings, or Resources. Additionally, you can create and define your own expression builder. The
expression value that follows the colon (:) is what ASP.NET will actually use
as the value of a certain property.The following demo shows how to use the expression builder to obtain the copyright of a Web site from the AppSettings node in the Web.config file and how to then set the copyright information as the value of the Literal’s Text property. The AppSettings node in Web.config file: http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx
(http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx)
<%-- ... -- %> server-side comments blockThe server-side comments block lets developers embed code comments in any location of the HTML source of ASP.NET Web Form pages (except for within <script> code blocks). Any content between the opening and closing tags of the server-side comments block will not be processed on the server or rendered on the resulting page.The following code example shows how to use the server-side comments block in an ASP.NET page: http://msdn.microsoft.com/en-us/library/4acf8afk.aspx
(http://msdn.microsoft.com/en-us/library/4acf8afk.aspx)
PropertiesArticle ID: 976112 - Last Review: October 20, 2009 - Revision: 2.0
|


Back to the top








