Archive for the ‘ASP, .NET Programming’ Category

Visual Web Developer Enhancements

Tuesday, November 18th, 2008

New Design View and CSS Design Tools

The Web page designer now lets you work in Design view, Source view, or Split view, which displays Design view and Source view at the same time.

Visual Studio now provides tools that make it easy to work with cascading style sheets (CSS). You can design the layout and style content in Design view by using new UI tools such as the CSS Properties window. You can also change positioning, padding, and margins directly in Design view by using WYSIWYG visual-layout tools.

For more information, see the following topics:

* Working with CSS Overview

* Walkthrough: Creating and Modifying a CSS File

IntelliSense for JScript and ASP.NET AJAX

Visual Studio 2008 and Visual Web Developer Express Edition now offer significantly improved IntelliSense for coding in ECMAScript (JScript or JavaScript), and for writing client script for AJAX-style Web applications that use the Microsoft AJAX Library. IntelliSense is available for client script in script elements and for referenced .js script files.

Additionally, IntelliSense displays XML code comments. XML code comments are used to describe the summary, parameter, and return details of your client script. ASP.NET AJAX also uses XML code comments to provide IntelliSense for ASP.NET AJAX types and members. IntelliSense is also supported for external script file references that use XML code comments.

For more information, see the following topics:

* JScript IntelliSense Overview

* Walkthrough: JScript IntelliSense

Web Application Projects

Web applications projects, released earlier as an add-on for Visual Studio 2005, are now integrated into Visual Studio and By using the Web application project model, you can compile a Web site into a single assembly in the Bin folder and explicitly define project resources.

The Web application project model uses the same project, build, and compilation semantics as Web projects in Visual Studio .NET 2003. This enables you to easily migrate Visual Studio .NET 2003 Web sites to the current version of Visual Studio or Visual Web Developer Express Edition.

Web application projects do not replace the Web site project type introduced in Visual Studio 2005. Instead, they provide another project model to provide more options for how you deploy and maintain Web applications.

For more information, see the following topics:

* Web Application Projects Overview

* How to: Create New Web Application Projects

Multi-targeting Web Applications

Visual Studio now enables you to target a Web application to a specific version of the .NET Framework. You can use one instance of the Visual Studio to develop Web applications for .NET Framework versions 2.0, 3.0 (Windows Vista), and 3.5. In Visual Web Developer Express Edition, you can only create applications that target the 3.5 version of the .NET Framework. However, you can later change the .NET Framework to target versions 2.0, 3.0, and 3.5 by changing the related project property.

For more information, see the following topics:

* .NET Framework Multi-Targeting Overview

* How to: Target a Specific .NET Framework

Designer and IntelliSense Support for LINQ

A new set of features in Visual Studio 2008 support Language-Integrated Query (LINQ) and extend the powerful query capabilities into the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and transforming data, and can be extended to support any kind of data source. The designer provides a visual representation of data classes that enables you to quickly create and edit classes that map to objects in a database. IntelliSense support provides information for LINQ language syntax and for using the LinqDataSource control in Source view. For more information, see LinqDataSource Web Server Control Overview
Support for Creating and Consuming WCF Services in a Web Project

In Visual Studio, you can add ASP.NET Web services (.asmx files) and WCF Web services (.svc files) to a project. Client applications that are written in managed code typically access these Web services through a proxy class. For example, these applications use the proxy class that Visual Studio generates when you use the Add Web Reference dialog box. AJAX applications can access Web services from the browser by using proxy classes that are automatically generated in client script. For more information, see ASP.NET Application Services Overview.
Support for ASP.NET AJAX Extender Controls

AJAX extender controls enhance the client capabilities of standard Web server controls in ASP.NET Web applications. You can provide a richer Web-based user experience by binding one or more extenders to Web server controls such as TextBox controls, Button controls, and Panel controls.

Visual Studio supports all ASP.NET AJAX extender controls. This includes extender controls that you create and those that you add from sources such as the ASP.NET AJAX Control Toolkit, which is available on the ASP.NET Web site.

Posted by

What’s New in ASP.NET and Web Development

Tuesday, November 18th, 2008

The .NET Framework version 3.5 Service Pack 1 includes enhancements for ASP.NET in targeted areas. Visual Studio 2008 and Microsoft Visual Web Developer Express Edition also include enhancements and new features for improved Web development.

The most significant advances are improved support for developing AJAX-enabled Web sites and support for Language-Integrated Query (LINQ). The advances include new server controls and types, a new object-oriented client type library, and full IntelliSense support in Visual Studio 2008 and Microsoft Visual Web Developer Express Edition for working with ECMAScript (JavaScript or JScript).

The following sections of this topic describe the changes in ASP.NET and Visual Web Developer.

* ASP.NET Enhancements in SP1
* ASP.NET Enhancements in version 3.5
* Visual Web Developer Enhancements

ASP.NET Enhancements in SP1

The following sections provide information about enhancements and new features in Visual Studio 2008 and Visual Web Developer Express Edition.

Dynamic Data

ASP.NET Dynamic Data is a framework that lets you create data-driven ASP.NET Web applications easily. It does this by automatically discovering the data model at run time and determining UI behavior from it. A scaffolding framework instantly provides a functional Web site for viewing and editing data. This scaffolding can then be easily customized using metadata, templates, or by creating standard ASP.NET pages to override the default behavior. At the same time existing applications can easily integrate pieces of the scaffolding logic with their existing pages.
URL Routing

URL routing in ASP.NET enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs in a Web application that are descriptive of the user’s action and therefore more easily understood by users. In URL routing, you define URL patterns that contain placeholders for values that are used when you handle URL requests. At run time, the pieces of the URL that follow the application name are parsed into discrete values, based on a URL pattern that you have defined.
EntityDataSource Control

The EntityDataSource control supports data binding scenarios based on the Entity Data Model (EDM). The EDM specification represents data as sets of entities and relationships. The EDM is used by the Entity Framework in object-relational mapping and in other scenarios such as ADO.NET Data Services. Users accustomed to the design-time model of ASP.NET data binding controls will find the programming surface of the EntityDataSource control similar to that of other data source controls.

The EntityDataSource control manages create, read, update, and delete operations with a data source on behalf of data-bound controls on the page. The EntityDataSource works with editable grids, forms with user-controlled sorting and filtering, dually bound drop-down list controls, and master-detail pages. The EntityDataSource control is able to obtain query parameter values from page controls, query parameters appended to the page URI, cookies, and other ASP.NET parameter objects.

New ASP.NET AJAX Extensions

The new extensions for ASP.NET AJAX in SP1 give you more control over browser history when you use the Back button. They also enable multiple client scripts to be automatically combined into one composite script. This speeds script load time by greatly reducing the required number of round trips to the server.

JScript Formatting

Code formatting capabilities has been extended to support JScript in Visual Studio and Visual Web Developer Express Edition. You can choose to format code manually for a document or selection, or to be automatically formatted as you type.
ASP.NET Enhancements in version 3.5

The .NET Framework version 3.5 includes enhancements for ASP.NET in the following areas:

* New server controls, types, and a client-script library that work together to enable you to develop AJAX-style Web applications.

* Extension of server-based forms authentication, roles management, and profile services as Web services that can be consumed by Web-based applications.

*A new EntityDataSource control that exposes the Entity Data Model through the ASP.NET data source control architecture.

*A new ListView data control that displays data and that provides a highly customizable UI.

* A new LinqDataSource control that exposes Language-Integrated Query (LINQ) through the ASP.NET data source control architecture.

*  A new merge tool (Aspnet_merge.exe) that merges precompiled assemblies to support flexible deployment and release management. This feature is not available in Visual Web Developer Express Edition.

The .NET Framework version 3.5 is also integrated with IIS 7.0. You can now use ASP.NET services such as forms authentication and caching for all content types, not just ASP.NET Web pages (.aspx files). This is because ASP.NET and IIS 7.0 use the same request pipeline. The unified request processing pipeline means that you can use managed code to develop HTTP pipeline modules that work with all requests in IIS. In addition, IIS and ASP.NET modules and handlers now support unified configuration. For more information, see ASP.NET Application Life Cycle Overview for IIS 7.0.
AJAX Development

The .NET Framework version 3.5 enables you to create Web applications that feature next-generation user interfaces with reusable client components. You can develop Web pages by using a server-based approach, a client-based approach, or a combination of both, according to your requirements. The AJAX server-based and client-based programming models feature the following:

* Server controls that support server-based AJAX development. This includes the ScriptManager, UpdatePanel, UpdateProgress, and Timer controls. These controls enable you to create rich client behavior with little or no client script, such as partial-page rendering and displaying update progress during asynchronous postbacks.

*The Microsoft AJAX Library, which supports client-based, object-oriented development that is browser independent. In addition to supporting the new AJAX-enabled server controls, the client library enables you to develop custom client components that extend DOM elements or that represent a DOM element.

* Server classes that enable you to develop server controls that map to custom client components whose events and properties are set declaratively. Server types that support this functionality include controls that derive from the ExtenderControl or ScriptControl base classes, or that implement the IExtenderControl or IScriptControl interfaces.
* Support for script globalization and localization by using client script. Globalization enables you to display dates and numbers based on a culture value (locale). Localization enables you to specify localized content (text, images, and so on) in client components for UI elements or exception messages.

* Access to Web services and to ASP.NET authentication, roles management, and profile application services.

The .NET Framework version 3.5 enables you to easily enable asynchronous partial-page updates in a page, which avoids the overhead of full-page postbacks. You can just put existing controls and markup inside UpdatePanel controls. Postbacks from inside an UpdatePanel control become asynchronous postbacks and refresh only the part of the page that is inside the panel, which creates a more fluid user experience. You can display the progress of the partial-page update by using UpdateProgress controls.
Learning About AJAX Development in ASP.NET

The documentation provides extensive information to help you learn how to develop AJAX-style Web applications in ASP.NET. To start, follow the sequence of topics described in Adding AJAX and Client Capabilities Roadmap.
Web Services and Application Services

The .NET Framework version 3.5 enables you to create both ASP.NET (.asmx) and WCF-based Web services that you can call from Web pages in client script by using the Microsoft AJAX Library. You can also call server-based application services that are exposed as Web services, which includes forms authentication, roles management, and profiles. These application services can be consumed in WCF-compatible applications, which includes AJAX-enabled Web pages and Window Forms clients. As a result, applications that are built with these ASP.NET or WCF technologies can share information that is made available by application services. For more information, see Web Services in ASP.NET AJAX and Using ASP.NET Web Services.
ListView Data Control

The ListView control combines many aspects of existing data controls. The ListView control is useful for displaying data in any repeating structure, similar to the DataList and Repeater controls. Unlike those controls, the ListView control supports edit, insert, and delete operations as well as sorting and paging. The paging functionality is provided for ListView by the new DataPager control.

The ListView control is a highly customizable control that enables you to use templates and styles to define the control’s UI. Like the Repeater, DataList, and FormView controls, templates in the ListView control are not predefined to render specific UI in the browser. For more information, see ListView Web Server Control Overview.
DataPager Control

The DataPager control is used to page through data that is displayed by a control that implements the IPageableItemContainer interface, such as the ListView control. The DataPager control supports built-in paging UI. You can specify the paging UI by using the NumericPagerField object, which lets users select a page by page number. You can also use the NextPreviousPagerField object, which lets users navigate through pages one page at a time, or to jump to the first or last page. Alternatively, you can create custom paging UI by using the TemplatePagerField object.
LinqDataSource Control

The LinqDataSource control exposes Language Integrated Query (LINQ) through the ASP.NET data source control architecture. You use the LinqDataSource control when you are creating a Web page that retrieves or modifies data and you want to use the programming model that is provided by LINQ. You can simplify the code in a Web page by enabling the LinqDataSource control to automatically create the commands for interacting with the data. By using the LinqDataSource control, you can reduce the amount of code that you must write to perform data operations when compared to performing the same operations in the SqlDataSource control or the ObjectDataSource control. When you use the LinqDataSource control, you also benefit by learning only one programming model to interact with different types of data sources.

You can use declarative markup to create a LinqDataSource control that connects to data from either a database or a data collection such as a collection. In the markup, you can specify the criteria for displaying, filtering, ordering, and grouping data. When the data source is an SQL database table, you can also configure a LinqDataSource control to update, insert, and delete data. You do not have to write the SQL commands to perform these tasks. The LinqDataSource class provides an event model that enables you to customize display and update behavior. For more information, see LinqDataSource Web Server Control Overview.

Posted by

Introduction to Visual Web Developer 2005 Express Edition

Tuesday, November 11th, 2008

Visual Web Developer 2005 Express Edition is part of the Microsoft Visual Studio 2005 family, and is the best development tool for building data driven web applications with ASP.NET 2.0. As part of the Express family, Visual Web Developer provides a seamless upgrade path to Visual Studio Standard, Professional, and Team System.

Visual Web Developer is tuned to the specific needs of the Web developer through a new Web profile that exposes a menu and window layout optimized for Web development. The environment includes a best-of-breed HTML source editor, an improved visual page designer, a new project system, better support for working with data, and full XHTML standards support.  Collectively, these features enable you to develop data-driven Web applications faster and easier than ever before. Below we’ll dive in and explore a few of the many Web development improvements coming with Visual Web Developer.

Better Source Code Editing

Visual Web Developer has an improved HTML source editor which enables you to write and modify your pages faster. The source editor provides full Intellisense throughout your files and has new features for navigating and validating your markup.

Intellisense Everywhere
Intellisense — the popup code hints which appear while you type — has a dramatic impact on your productivity as a developer. While support for Intellisense in Visual Studio .NET 2003 is excellent today, support for Intellisense in Visual Web Developer gets even better.

In Visual Web Developer, Intellisense pops up everywhere. For example, you can take full advantage of Intellisense within the script blocks in single file ASP.NET pages. In addition, Visual Web Developer also supports Intellisense for ASP.NET Page Directives and for inline CSS style attributes within a page.
HTML Formatting Options
Visual Web Developer enables you to precisely control the format of all HTML and ASP.NET Server Control markup generated using the WYSIWYG designer.  You can now configure the tag casing, attribute quotation, indention style and word wrap characteristics of every html or server control tag in a page.  You can set these formatting options as defaults for all markup, as well as optionally override each formatting option on a per tag/control basis.  This provides you with the flexibility to fully control exactly how you want your markup to be generated.

HTML format settings can be exported and imported from Visual Web Developer to enable markup style standardization across multiple developers on a team.  Visual Web Developer also enables developers to easily apply HTML formatting rules to existing markup source (to handle those cases when you need to update existing HTML source with new formatting rules).

Tag Navigator
The HTML source editor within Visual Web Developer ships with a new �Tag Navigator� feature that enables developers to easily track their location and navigate within a complicated HTML document. The Tag Navigator displays the current “path” within the source of an HTML page by displaying a list of all the HTML tags which contain the tag where your cursor is currently located. Clicking on any of the nodes enables developers to optionally change the source level selection, and quickly move up and down a deep HTML hierarchy.

Imagine, for example, that you are editing the source of an HTML page with multiple nested HTML tables. Editing nested tables can be challenging since it is easy to get lost within the jumble of nested table rows and cells. However, by taking advantage of the Tag Navigator, you can avoid getting lost since the Tag Navigator continuously displays your current path within the hierarchy of table elements.

Tag Outlining
Tag Outlining enables you to work more effectively with large HTML documents. With Tag Outlining, you can right-click any HTML tag in the source editor and select Collapse Tag to hide the entire contents of the tag. Collapsing different regions of the HTML source code contained in a page makes it easier to focus on the particular region of the page which you need to edit.

Posted by

What’s New in ASP.NET 2.0?

Tuesday, November 11th, 2008

ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications. The first version of ASP.NET offered several important advantages over previous Web development models. ASP.NET 2.0 improves upon that foundation by adding support for several new and exciting features in the areas of developer productivity, administration and management, extensibility, and performance:
Developer Productivity
ASP.NET 2.0 encapsulates common Web tasks into application services and controls that can be easily reused across web sites. With these basic building blocks, many scenarios can now be implemented with far less custom code than was required in previous versions. With ASP.NET 2.0 it is possible to significantly reduce the amount of code and concepts necessary to build common scenarios on the web.

* New Server Controls. ASP.NET 2.0 introduces many new server controls that enable powerful declarative support for data access, login security, wizard navigation, menus, treeviews, portals, and more. Many of these controls take advantage of core application services in ASP.NET for scenarios like data access, membership and roles, and personalization. Some of the new families of controls in ASP.NET 2.0 are described below.

o Data Controls. Data access in ASP.NET 2.0 can be accomplished completely declaratively (no code) using the new data-bound and data source controls. There are new data source controls to represent different data backends such as SQL database, business objects, and XML, and there are new data-bound controls for rendering common UI for data, such as gridview, detailsview, and formview..

o Navigation Controls. The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.

o Login Controls. The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.

o Web Part Controls. Web parts are an exciting new family of controls that enable you to add rich, personalized content and layout to your site, as well as the ability to edit that content and layout directly from your application pages. These controls rely on the personalization services in ASP.NET 2.0 to provide a unique experience for each user in your application.

Posted by

Master Pages and CSS StyleSheets

Friday, October 10th, 2008

A common problem that often arises from using Master Pages is the confusion about how to reference a CSS StyleSheet from a page within a Master Page. The problem is that the <head> section of the markup is located in the Master Page, so the reference to the StyleSheet cannot be made… seemingly. The trick is to add some code to the Page Load event of the page that need access to the StyleSheet.

This little snippet of code comes in handy during these situations:

Dim link As New HtmlLink
link.Href = “LocationOfMyStyleSheet.css”
link.Attributes.Add(HtmlTextWriterAttribute.Rel.ToString(), “stylesheet”)
Page.Header.Controls.Add(link)

Posted by

Advantages of ASP.NET

Friday, October 10th, 2008

A single CLR operating system process can contain multiple application domains. There are advantages to having application domains within a single process.

  1. Lower system cost - many application domains can be contained within a single system process.

  2. Each application domain can have different security access levels assigned to them, all within a single process.

  3. Code in one AppDomain cannot directly access code in another AppDomain.

  4. The application in an AppDomain can be stopped without affecting the state of another AppDomain running in the same process.

  5. An  Exception in on AppDomain will not affect other AppDomains or crash the entire process that hosts the AppDomains.

Posted by

AppDomain concept in ASP.Net

Friday, October 10th, 2008

Asp.Net introduces the concept of an Application Domain which is shortly known as AppDomain. It can be considered as a Lightweight process which is both a container and boundary. The .NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside of a secure boundary.

The CLR can allow the multiple .Net applications to be run in a single AppDomain.

The CLR isolates each application domain from all other application domains and prevents the configuration, security, or stability of a running .NET applications from affecting other applications.An AppDomain can be destroyed without effecting the other Appdomains in the process.

Mulitple Appdomains can exist in Win32 process. As we discussed the main aim of AppDomain is to isolate applications from each other and the process is same as the working of operating system process. This isolation is achieved by making sure than any given unique virtual address space runs exactly one application and scopes the resources for the process or application domain using that address space.

Win32 processes provide isolation by having distinct memory addresses. The .Net runtime enforces AppDomain isolation by keeping control over the use of memory. All memory in the App domain is managed by the run time so the runtime can ensure that AppDomains Do not access each others memory.

Posted by

Creating Images Dynamically

Tuesday, September 30th, 2008

Ask any ASP developer who has ever tried to dynamically create his own images and he?ll tell you it?s a nightmare. In fact, it?s more than a nightmare. It?s practically hell. The only true solution? Reverting to an expensive, dodgy, third-party control to do the work for you.

With ASP.NET, however, you can develop your own dynamic images with ease. Simply create an image object and use the new GDI+ features to add objects to that image, such as text, rectangles, and ellipses. After that, you can simply stream straight back down to the client.

But covering the graphics features in depth would require at least another two books, and, unfortunately, we don?t have that much room. So, I?m going to share a sample that demonstrates creating a small ?Drawing? button, alongside a little blue-and-yellow bullet point.It?s the sort of personalized graphic you?ll find on sites such as Amazon.com.

Posted by

Stopping Your User from Right-Clicking

Tuesday, September 30th, 2008

Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It?s not foolproof, but this neat little HTML edit usually does the trick.

Just alter the opening <body> tag of your HTML to the following:

<BODY oncontextmenu=”return false”>

When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!

Posted by

Smart navigation

Tuesday, September 30th, 2008

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the <pages> tag to the following location within your Web.config file:

Note that smart navigation works on only Internet Explorer 5 and above; however, ASP.NET will automatically detect this and serve up the ?smart? code only if the target browser supports it.

Also, I?d personally advise that you test it against any third-party menu controls or scripts you may have running: it is prone to falling over on particularly advanced pages.

Posted by