Escolar Documentos
Profissional Documentos
Cultura Documentos
0
Tips and Tricks
Scott Guthrie
General Manager
Microsoft Developer Division
scottgu@microsoft.com
http://weblogs.asp.net/scottgu
Agenda
• Visual Studio Project Tips/Tricks
• ASP.NET UI Tips/Tricks
• ASP.NET AJAX Tips/Tricks
• ASP.NET Caching Tips/Tricks
• ASP.NET Deployment Tips/Tricks
Download Slides + Demos
http://weblogs.asp.net/scottgu
Visual Studio Project
Tips and Tricks
VS 2005 Web Project Options
• VS 2005 Web Site Project Model
• File-system based project model
</asp:panel>
</form>
</body>
</html>
Default Focus
• Enable developers to identify default focus
behavior when page is loaded
• Cross browser: works with all modern browsers
</asp:panel>
</form>
</body>
</html>
SetFocusOnError
• Enable developers to force focus on a
control when a validation error occurs
• Set as a property on the validation control
<asp:RequiredFieldValidator
SetFocusOnError="true"
ErrorMessage="TextBox3 is empty"
ControlToValidate="TextBox3"
runat="server“/>
Default Button and Focus
Clean HTML using CSS Adapters
• ASP.NET 2.0 introduced Control Adapter API
• Enables developers to override rendering of controls
• Does not change the control’s API
<controls>
<add tagPrefix="acme" tagName="uc" src="controls/uc.ascx" />
<add tagPrefix="my" namespace="MyControls.Basic" assembly="MyControls" />
</controls>
Control Registration in
Web.config
Server Side Comments
• Useful feature for preventing server
code/controls from running on HTML
being sent to the server:
<%--
Everything in here commented out
--%>
<ajaxToolkit:CollapsiblePanelExtender TargetControlID="detailsPanel“
CollapseControlID="ShowHideBtn"
ExpandControlID="ShowHideBtn"
Collapsed="true"
SuppressPostBack="true"
runat="server“ />
PopUpControlExtender and
CollapsablePanelExtender
Some of the AJAX
Control Toolkit Extenders
• AutoCompleteTextBoxExtender • ModalPopupExtender
• CollapsablePanelExtender • MutuallyExclusiveCheckboxExtender
• AnimationExtender • NumericUpDownExtender
• ConfirmButtonExtender • PasswordStrengthExtender
• DragPanelExtender • PopUpControlExtender
• DropShadowExtender • ResizableControlExtender
• AlwaysVisibleExtender • RoundedCornersExtender
• DynamicPopulateExtender • SliderExtender
• FilteredTextBoxExtender • TextBoxWaterMarkExtender
• HoverMenuExtender • UpdatePanelAnimationExtender
• ValidatorCalloutExtender
AJAX Control Toolkit Extenders
Building your own Extenders
• ASP.NET AJAX “Core” includes classes
needed to build your own extenders
• ExtenderControlBase class
• JavaScript framework for encapsulating classes
• AJAX network hooks and postback integration
• Declaratively enable:
• <%@ OutputCache Duration=“10” varybyparam=“none” %>
• <%@ OutputCache Duration=“10” varybyparam=“none” shared=“true” %>
Page and Partial-Page Caching
Substitution Control
• New feature with ASP.NET 2.0
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ProductPages" duration="50000" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
ASP.NET
Deployment Tips/Tricks
App_Offline.htm
• Enables you to gracefully take a server
application “offline” for maintenance
• Useful when making big changes/upgrades
• Bad consequences:
• Debug compilation slows performance
• App uses much more memory
• Client-side scripts are not cached
<ItemTemplate>
</ItemTemplate>
</asp:DataList>
<RssToolkit:RssDataSource ID="MyRssFeed"
Url="http://weblogs.asp.net/scottgu/Rss.aspx"
MaxItems="10"
runat="server" />
RSS Reader
Summary
• Enormous number of new features in
ASP.NET 2.0
• Tons of additional cool features out there…
</asp:panel>
</form>
</body>
</html>
Default Focus
• Enable developers to identify default focus
behavior when page is loaded
• Cross browser: works with all modern browsers
</asp:panel>
</form>
</body>
</html>
SetFocusOnError
• Enable developers to force focus on a
control when a validation error occurs
• Set as a property on the validation control
<asp:RequiredFieldValidator
SetFocusOnError="true"
ErrorMessage="TextBox3 is empty"
ControlToValidate="TextBox3"
runat="server“/>
Default Button and Focus