subject: ASP.NET 4.0 Hosting :: Data Web Controls Enhancements in ASP.NET 4.0 [print this page] ASP.NET 4.0 Hosting :: Data Web Controls Enhancements in ASP.NET 4.0
Traditionally, developers using Web controls enjoyed increased productivity but at the cost of control over the rendered markup. For instance, many ASP.NET controls automatically wrap their content in
for layout or styling purposes. This behavior runs counter to the web standards that have evolved over the past several years, which favor cleaner, terser HTML; sparing use of tables; and Cascading Style Sheets (CSS) for layout and styling. Furthermore, the elements and other automatically-added content makes it harder to both style the Web controls using CSS and to work with the controls from client-side script.
Disabling The Outer Table in Templated Controls
In ASP.NET 3.5, a number of Web controls that use (or can use) templates automatically wrap the rendered templated content within a
element. One such control that displays this behavior is the FormView control. To see how the FormView wraps the output in a elements for styling purposes. These tags can now be optionally suppressed with a new property, RenderOuterTable. Similarly, the CheckBoxList and RadioButtonList controls' RepeatLayout property has been expanded to include two new settings - OrderedList and UnorderedList - which offer developers alternative ways to influence the markup generated by these controls.
Also, the ListView control has been tidied up a bit, making the LayoutTemplate optional.
What is so SPECIAL on ASPHostDirectory.com ASP. Net 4 Hosting?
We know that finding a cheap, reliable web host is not a simple task so we've put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.
We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.
The followings are the top 10 reasons you should trust your online business and hosting needs to us:
- FREE domain for Life -ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There's no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it's customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people's uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a no questions asked' money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in ASP. Net 4 Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control Panel in 1 minute!
Happy Hosting!
element automatically added to the markup defined in the template. In short, the FormView control wraps its templated content within a one row, one column table, whether we like it or not.
The FormView renders this outer
to express style information. The FormView has a property named RowStyle, which contains a variety of substyles (BackColor, Font, BorderColor, and so on). For example, if the RowStyle's BackColor and Font-Size properties are set to Red and Larger, respectively, the FormView will render the following markup:
Beverages
Soft drinks, coffees, teas, beers, and ales'
Note how the
(specifically the element) specifies the style as defined by the FormView's RowStyle property. Therefore, this outer element is useful when using the RowStyle property, but is extra cruft if the RowStyle property is not being used or if the style information is specified directly in the template's markup (using CSS classes, ideally).
ASP.NET 4.0 adds a new Boolean property to the FormView and a host of other Web controls named RenderOuterTable. This property, when set to True (the default), renders the outer
element as was done in ASP.NET 3.5 and earlier versions. If this property is set to False, however, then the outer is omitted.
Taking our earlier FormView example, let's see what would happen if we set RenderOuterTable to False.
'
With that minor change, the rendered markup for the FormView no longer includes the outer table. Instead, the FormView renders just the contents of its template(s), as the following snippet of HTML shows:
Beverages
Soft drinks, coffees, teas, beers, and ales'
When RenderOuterTable is set to False, any styles that are expressed through that outer table are no longer rendered. In short, any style settings to the RowStyle property will be ignored when the above FormView is rendered.
In addition to the FormView, the RenderOuterTable property has been added to the following Web controls in ASP.NET 4.0:
- Login
- PasswordRecovery
- ChangePassword
- Wizard
- CreateUserWizard
ListView Control Enhancements
The ListView control displays a set of data records using templates. Like the GridView, the ListView supports paging, sorting, editing, and deleting data. It can also be used to insert data. Developers using the ListView control in ASP.NET version 3.5 had to provide at least two required templates:
- ItemTemplate - specifies the markup rendered for each item bound to the ListView
- LayoutTemplate - specifies the ListView's encasing markup and contains a Web control that indicates where the ItemTemplate's markup should be placed
In most scenarios, the LayoutTemplate would contain nothing but a Web control to specify where the ItemTemplate's markup should appear, resulting in a ListView with markup like the following:
...
The LayoutTemplate in the above example serves no purpose other than to say, "Here is where the ItemTemplate markup should go." Regardless, with ASP.NET 3.5 you still had to define this LayoutTemplate explicitly in the ListView's markup.
The good news is that with ASP.NET version 4.0 you can omit the LayoutTemplate - the ItemTemplate is now the only required template in the ListView. The following snippet of declarative markup shows this new abbreviated syntax:
...
New RepeatLayout Options for the CheckBoxList and RadioButtonList Controls
The CheckBoxList and RadioButtonList controls display a set of check boxes or radio buttons based on some data and are useful for building a set of check boxes or radio buttons based on a database query. Both of these controls have a RepeatLayout property that dictates how the series of check boxes or radio buttons are laid out. In ASP.NET 3.5 there were two possible settings for this property:
- Table (the default) - lays out the items using a
element. By default, each check box or radio button is laid out in its own table row. Use the RepeatColumns property to have a fixed number of check boxes or radio buttons displayed per row
- Flow - lays out each check box or radio button in a element with a line break (
) after each element, by default. The RepeatColumns property, if set, indicates that a line break should only be rendered after a certain number of check boxes or radio buttons.
ASP.NET 4.0 adds two additional settings to the RepeatLayout property:
- OrderedList - lays out the items using an
Beverages
Condiments
Confections
).
The idea with the OrderedList and UnorderedList options is that the check boxes or radio buttons can be laid out using CSS. There are many web pages that discuss how to use CSS to layout elements in ordered and unordered lists.
Conclusion
ASP.NET 4.0 gives Web Form developers greater control over the rendered markup. Many templated controls that had previously added