22.6.10

Web Parts

WebParts give us the option of dragging and dropping of objects on a page as well as, changing titles and border style properties of objects at runtime. Before the introduction of WebParts it was used to be a hectic task because we had to write a lot of JavaScript and had to save the state of objects in a database.

There are two basic things in WebParts:

* WebPart manager

* WebPart zones



* WebPart manager

The WebPartManager is the manager for all webparts. If you use webparts in your web projects you are required to use the WebPartManager. Usually you just drag and drop this into your webform and are ready to go.

* WebPart zones

There are four kinds of zones in webpart zones:

ü WebPart Zone

ü Editor Zone

ü Catalog Zone

ü Connection Zone


Reference: http://dotnetslackers.com/articles/aspnet/UsingWebPartsInASPNet20.aspx

Difference between Debug & Release Build Mode

Debug Mode:
* In debug mode, many of the compiler optimizations are turned off which allow the generated executable match up with the code. This allows breakpoints to be set accurately and allows a programmer to step through the code one line at a time. Debugging information is also generated help the debugger figure out where it is in the source code.
* Debug compile generates .pdb files containing debugging information.
* When an application is built using Debug build, a .pdb file is generated in the bin folder while this does not happen in Release build.
* There will be a speed difference, because of disabling debug methods.
* In release mode, most of the compiler's optimizations are turned on. Chunks of your code could be completely deleted, removed, or rewritten. The resulting executable will most likely not match up with your written code. However, normally release mode will run faster than debug mode due to the optimizations.

Release Mode:
* Production release should be strictly release mode only. This is because debug compilation considerably increases memory footprint since debug symbols are required to be loaded. Additionally it will hit the performance because that will include the optional debug and trace statements in the output IL code.
* The compiler emits an instance of the System.Diagnostics.DebuggableAttribute. In the debug version, the IsJitOptimizerEnabled property is True, in the release version it is False. You can see this attribute in the assembly manifest with ildasm.exe.
* The JIT compiler uses this attribute to disable optimizations that would make debugging difficult. The ones that move code around like loop-invariant hoisting. In selected cases, this can make a big difference in performance. Not usually though.
* Mapping breakpoints to execution addresses is the job of the debugger. It uses the .pdb file and info generated by the JIT compiler that provides the IL instruction to code address mapping. If you would write your own debugger, you'd use ICorDebugCode::GetILToNativeMapping().
* The Debug mode does not optimize the binary it produces (as optimizations can greatly complicate debugging), and generates additional data to aid debugging.
* The Release mode enables optimizations and generates less (or no) extra debug data.

You can append the following code to the AssemblyInfo.cs file:

#if DEBUG

[assembly: AssemblyDescription("Debug")]

#else

[assembly: AssemblyDescription("Release")]

#endif

After compiled to Assembly file (.dll or .exe), right-click the file and check its version property: Comments item is Dubug or Release.

10.6.10

Features in SQL 2005

Features in SQL 2005
===============
*Integrated common language runtime (CLR) support. Stored procedures and functions can be written using your favorite programming language.
*Native XML support.
*XCopy support for moving databases from one location to another.
Robust and reliable installation using either graphical user interface (GUI) or silent modes.
Automated servicing and patching.
*Deep integration with Visual Studio to provide access to rich data controls like the DataGridView, DataNavigator, and DataConnector.
Support for databases up to 4GB.
Support for disconnected systems with SQL Server Service Broker and Replication.
SQL Server Express Manager, a new, easy-to-use database management and query analysis tool.
Easier deployment via Visual Studio ClickOnce (available in Beta 3).

Validation Controls

* Validation Controls
- CompareValidator
We need to compare user input to another value (e.g., another property or constant) in a style similar to the old and ever lasting if statement.
- CustomValidator
Your validation needs does not fit on any of the categories specified in this table but you are still able to write code that checks for the validity of this input.
Here you can use the ValidateEmptyText property to do validation even if the validation value is empty. This is a new feature in ASP.NET 2.0
- RangeValidator
You need to be sure whether the input falls between two bound (Example: User age must be between 18 and 99)
- RegularExpressionValidator
You need the input to follow a consistent pattern (Example: a phone number that must start with '+' and must be composed of 9 to 10 digits)
- RequiredFieldValidator
You need to force the user to input a value inside a particular control and not to leave it empty. (Example: The User Name field in a login form)

General Tips

* Uninstall software’s Without Using Add / Remove Programs:

Approach using Installer

Run->type installer ->
· RClick the msi.

· select properties.

· Go to summary.

· check the title of msi / software name which you want to uninstall.

· RClick the appropriate msi / software and select UnInstall.

25.2.10

Different Types of Paths



There are two options

* Absolute Paths
Link uses the full URL of an object or page. While you can use it within your own site, there is rarely ever a need to do so.

* Relative Paths
Any time you need to send a visitor to another page within your site or include an object from your site (like an image) on one of your pages a relative link will work just fine.

- Document Relative
It is the most widely used type of relative linking, and for good reason. They can easily move up and down your site's hierarchy, in and out of directories (folders) without a hitch.
eg:OPEN img src="images/title.gif" CLOSE
See the above image instead of the products page being in the same directory as the home page it is actually located in a subdirectory. You still need to include the images in the page but the page is in a directory (folder) deeper than the root level of your site.
As you can see you need to move up and out of the products directory in order to get to the images folder in order to access the needed images
eg:OPEN img src="../images/title.gif" CLOSE

- Root Relative
A site root-relative path describes the location of the destination file by describing the route the browser must take from the Web site's root folder (top level in the folder structure).
eg:OPEN img src="/html/images/image1.gif" CLOSE
"/" denotes root directory
You just need to use the System.Web.VirtualPathUtility.ToAbsolute("~") method to convert the ~ to the ApplicationPath.So, if your file is located at "~/common/images/spacer.gif" and you need to specify this path in a client tag like OPEN img CLOSE, ASP.NET would not allow you to use this path unless you use a Server Control like OPEN asp:Image CLOSE.
To continue using the client tag you can use:
OPEN img src="OPEN %=System.Web.VirtualPathUtility.ToAbsolute("~")%CLOSE /common/images/spacer.gif" / CLOSE
and this would be resolved to "/MyApplication/common/images/spacer.gif" where the first forward slash (/) stands for the WebSite root. Thus, the tilde "~" is effectively resolved to "/MyApplication"
Alternatively, Control.ResolveClientUrl can be used. For example
OPEN img src='<%= ResolveClientUrl("~/common/images/spacer.gif")%>' / CLOSE

8.1.10

Server.Transfer Vs Response.Redirect

* Response.Redirect
-It involves a roundtrip to the server.
-you cannot directly access the values, controls and properties of the previous page.
-Suppose you are currently on the Page1.aspx and now you are transferring the user to the Page2.aspx using Response.Redirect then When the Page2 page is requested, Page1 has been flushed from the server’s memory and no information can be retrieved about it unless the developer explicitly saved the information using some technique like session, cookie, application, cache etc
-Response.Redirect can be used for both .aspx and html pages
-Response.Redirect can be used to redirect a user to an external websites.
* Server.Transfer
-It conserves/Preserves server resources by avoiding the roundtrip.
-you can directly access the values, controls and properties of the previous page which you can’t do with Response.Redirect.
-variables can stay in scope and Page2 can read properties directly from Page1 because it’s still in memory, as you know the Server.Transfer just changes the focus from page1 to page2 So in this case browser doesn’t know that any change is happen there that’s why with this method you can access the information about the previous page.
-Server.Transfer can be used only for .aspx pages and is specific to ASP and ASP.NET.
-Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.
- you can put values into the Context.Items dictionary for using these values in next page.
eg.
Context.Items["Message"] = "Your password was changed successfully";
Server.Transfer("default.aspx");