F9 Group Marketing and Technology Blog

Marketing, Technology, and current news at http://www.f9group.com/

Entries Tagged ‘declarative’

Building Interactive User Interfaces with Microsoft ASP.NET AJAX: Triggering Full Page Postbacks From An UpdatePanel

The ASP.NET AJAX UpdatePanel provides a quick and easy way to implement a snappier, AJAX-based user interface in an ASP.NET WebForm. In a nutshell, Web controls within the UpdatePanel that would normally cause a full page postback trigger a partial page postback, instead. For example, a Button Web control, when clicked, submits the form, causing the browser to start a full page postback. However, if the Button control is within an UpdatePanel then the UpdatePanel short-circuits the full page postback and performs a partial page postback, using JavaScript to make an HTTP request to the server. The server realizes that the request is a partial page postback (and not a full page postback) and only returns the markup for the UpdatePanels on the page. When this response is returned to the browser, JavaScript code parses it and seamlessly updates the user interfaces in the UpdatePanels. (For a more in-depth look at the UpdatePanel control, refer back to the Using the UpdatePanel installment in this article series.) While we usually want controls within the UpdatePanel to perform a partial page postback, there are scenarios where we need a full page postback

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

skmExpressionBuilders – A Suite of Custom Expression Builder Classes

An ASP.NET Web control’s properties can be set in one of two ways: declaratively and programmatically. Declaratively setting a Web control’s properties entails specifying the property in the control’s declarative syntax. For example, Web controls have their ID property set declaratively, like so: <asp: WebControl runat=”server” ID=” ID ” … /> . Properties can also be set programmatically in the ASP.NET page’s code-behind class. If you need to set a Web control’s property to some dynamic value you may think you need to set it programmatically. However, this is not the case. Expression builders make it possible to assign a dynamic value to a Web control property through the declarative syntax. Last week’s article, Using Expression Builders in ASP.NET , examined the ins and outs of expression builders, their syntax, and how to use them in an ASP.NET page. ASP.NET ships with three built-in expression builder classes: AppSettingsExpressionBuilder , which retrieves a value from the <appSettings> section defined in Web.config ; ConnectionStringsExpressionBuilder , which retrieves a value from the <connectionStrings> section; and ResourceExpressionBuilder , which retrieves a resource value

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

Using Expression Builders in ASP.NET

ASP.NET offers a variety of ways to inject the results of a server-side expression (such as DateTime.Now.ToString() ) into the rendered markup of an ASP.NET page. The most common way is to add a Label Web control to the page and then from the Page_Load event handler (or some other suitable event handler) assign the value to display to the Label’s Text property. If you ever created web applications using ASP.NET’s predecessor, classic ASP, or if you are familiar with Microsoft’s ASP.NET MVC , then you know that another way to inject server-side information is to add <%= expression %> to the declarative content like so: The current time is: <%= DateTime.Now.ToString() %> The <%= expression %> syntax is translated into Response.Write( expression ) , injecting the value of expression into the page’s rendered output. Because <%= expression %> is translated into (essentially) a Response.Write these statements cannot be used to set the values of Web control properties. In other words, you cannot have markup like the following: <asp:Label runat=”server” id=”CurrentTime” Text=”<%= DateTime.Now.ToString() %>” /> An alternate way to display server-side information is to assign it to a Web control property directly from the declarative markup using an expression builder . An expression builder is denoted using the syntax <% $ expression %> (note the $ after <% ). The expression cannot be an arbitrary snippet of code as with <%= ..

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz