February 2009 Entries

There are a few ways of deploying a .NET 2.0 ASP.NET application

  • using Web Site Deployment Project
  • using VS.NET Publish Command
  • using VS.NET Build Command

1.) Using VS.NET Build

ASP.NET not Visual Studio performs the build.  ASP.NET builds everything, including .cs and .vb code files and places all resulting assemblies in folder structure under Temporary ASP.NET files directory.  As ASP.NET does all of the compilation, the debug setting in the compilation section of the web.config controls debug or release mode.  Compile with debug=true and you'll find the .pdb debugging symbol files alongside each assembly.  In this scenario the Configuration Manager is obsolete (not used) and as such the only option is 'Debug'.

 

2.) Using VS.NET Publish

This option is available when you are ready to publish to production.  The Publish command will precompile a web application and place the results into a director of your choosing (IIS/FTP/Directory).  Options are available on the Publish dialog box that map to aspnet_compiler switches.  The aspnet_compiler tool has option to create pdb files however this is not available on the dialog box (within vs.net).  Publish always builds in release mode without pdb files.  The Publish command does not change the debug setting in the web.config SO if you precompile and updateable (option 'allow this precompiled site to be updateable') web site and then update the web site in place (which will result in a dynamic compilation) those dynamic compilations will produce debug code and pdb files.

image

3.) Using Web Site Deployment Project (WSD)

This project allows VS.NET to use MSBUILD files provided by WSD to ask for debug and release builds.  This tool uses the aspnet_compiler similar to above with the Publish option however the WSD option will change the debug setting in the web.config to false for release builds (different than the Publish option)  By default the built files will be in respective debug or release directories.

 

Conclusion

VS.NET Build - builds web site to Temporary ASP.NET files directory with options specified in web.config

VS.NET Publish - builds to release mode (always) however does not change the compilation mode in web.config file (which can lead to less than optimum performance if site is dynamically recompiled)

Web Deployment Project - Builds based on Configuration Manager mode (debug/release) AND updates the web.config with additional options for creating debug symbols and swapping out web.config sections based on release mode

 

 

see related post http://blog.davidyardy.com/archive/2008/07/05/asp.net-2.0-compilation-models-again.aspx

category: Feature

1.) Download install VS.NET 2008 SP1 patch

Visual Studio 2008 SP1 has the following patch to allow IntelliSense with jQuery found here.  Note: this is a patch that is applied after .NET 3.5 SP1 and Visual Studio 2008 SP1.  Information about this patch can be found here.

I did find that the vsdoc.js version must match the version of jquery in order for the intellisense to function correctly.  If the versions mismatch intellisense will not work.

2.) Download jQuery documentation library

image

3.) Download jQuery 

image

4.) Copy both 2 and 3 to your solution Scripts folder

image

5.) In your aspx reference the jquery file

<script src="Scripts/jquery-1.2.6.min.js" type="text/javascript"></script>

or

<asp:ScriptManager runat="server" ID="scriptmanager1">
    <Scripts>
        <asp:ScriptReference Path="~/Scripts/jquery-1.2.6.min" />
    </Scripts>
</asp:ScriptManager>

Some Quick Tips

  • If you are using a master page the script reference only needs to exist in the master page
  • javascript intellisense will not work in user controls by default as the user control doesn’t have a reference to the js file.  A work around (use the following at the top of the user control).  At runtime ASP.NET will not render this tag however Visual Studio will evaluate the script and provide intellisense
    <% if (false) { %>
          <script src=”../Scripts/jquery-1.2.6.min.js” type=”text/javascript”></script>
    <% } %>
  • a recommended method of including js files is to create one js file which entail will include references to any number of specific js files, then on your web page include a reference to this one single js file
    <reference path=”~/Scripts/jquery-1.2.6.min.js” />
  • a good approach is to remove the version number from the jquery files to allow easier updates to these files in the future

Path(s) for Script References

  • File-Relative Paths i.e. ../../file.js This type of path is relative to the currently loaded file.  Support - ASP.NET Web forms / MVC
  • App-Relative Paths i.e. ~/folder/file.js  Is calculated from the base of your application.  ASP.NET Web forms supports this type of path however the path must be within a scriptreference tag or select asp.net controls which have runat=”server”
  • Site-Relative Paths i.e. /folder/file.js  Is calculated from the base of your site.  Supported by ASP.NET Web forms / MVC however is not supported by Visual Studio
  • Absolute Paths i.e. http://site/folder/file.js  Supported by ASP.NET Web forms / MVC and Visual Studio

If using Visual Studio(ASP.NET Web forms) recommended to use App-Relative paths ~/folder/file.js.  If using MVC use file-relative paths.

I had a need to compare two SQL Server table for differences between them.  I started using .NET dataset features (merge, acceptchanges, getchanges) as follows:

        Dim data1 DataSet = GetData1() 

        Dim data2 DataSet = GetData2() 

 

        Dim ds As New DataSet

        ds.Merge(data1)

        ds.AcceptChanges()

        ds.Merge(data2)

        ds.GetChanges(DataRowState.Modified)

There are a few gotcha's with the above code.  The primary problem was that both tables must have primary keys defined.  I figured ok, I could create primary keys through code for the related DataTables however I soon realized that there were duplicate rows within the tables.

SQL Server 2005 has Except and Intersect functions (http://msdn.microsoft.com/en-us/library/ms188055(SQL.90).aspx) that return distinct values by comparing the results of two queries.  The entire row is compared against another row from another table.

Except returns any distinct values from the left query that are not found on the right query.
Intersect returns any distinct values that are returned by both the query on the left and right sides.

In order to use the number and order of the columns must be the same in the queries and also the data types must be comparable. 

To return all rows in table1 that do not match exactly the rows in table2, you can use Except ...
select * from table1 except select * from table2

(likewise to find the opposite just reverse the table names above)

To return all rows in table1 that match exactly what is in table2, using Intersect...
select * from table1 intersect select * from table2

Combining the above two... (the following will return the differences)
select 'table1' as tblName, *  from
  (select * from Table1 except select * from Table2) x
union all
select 'table2' as tblName, *  from
  (select * from Table2 except select *  from Table1 ) x


If you are fortunate to have primary keys you can of course still use IN/NOT IN type queries however it seems that performance is much improved with the Except/Intersect approach.

 

category: SQL Server

Recently, Microsoft released their ASP.NET AJAX Framework which allows developers to build AJAX applications more easily.  ASP.NET AJAX consists of two pieces. 

1.) Microsoft AJAX Library - contains a set of script files that provide common functions and an OO programming framework

2.) ASP.NET 2.0 AJAX Extensions - includes a set of server controls that allows developers to add AJAX functionality by dragging and dropping controls onto a page

The following are brief descriptions of the javascript extensions made available by the AJAX Client Library by Namespace.

Global Namespace - contains members and types that extend base JavaScript objects.

Array Extensions (add, addRange, clear, clone, contains, dequeue, enqueue, forEach, indexOf, insert, pars, remove, removeAt)

Boolean Extension (parse - converts a string into a Boolean)

Date Extension (format, localeFormat, parseInvariant, parseLocale)
        var today = new Date();
        alert (today.format('D'));

        d - Short date pattern (05/10/07)
        D - Long date pattern (Thursday, 10 May 2007)
        t - Short time pattern (18:05)
        T - Long time pattern (18:05:12)
        F- Full date pattern (Thursday, 10 May 2007 18:05:12)
        M - Month and date pattern (May 10)
        s - Sortable date and time pattern (2007-05-10T18:05:12)
        Y - Year and month pattern (2007 May)

Error Extensions (argument, argumentNull, argumentOutOfRange, argumentType, argumentUndefined, create, invalidOperation, notImplemented, parameterCount, popStackFrame)

Number Extension (format, localeFormat, parseInvariant, parseLocale)

        p - number is converted to a string that represents a percent
        d - converted to a string of decimal digits
        c - converted to a string that represents a currency
        n - converted to a string of the form "-d,ddd,dd"

        var num = Number.parseInvariant("130.33");
        alert (num.localeFormat("c")); // $130.33

Object Extensions (getType, getTypeName)
        getType - returns the type of specified object
        getTypeName - returns the type name of an object

String Extension (endsWith, format, localeFormat, startsWith, trim, trimEnd, trimStart)

Sys Namespace

         Sys - root namespace containing some base classes such as Sys.CultureInfo
                  Application - objects/methods that expose client events and manage client components
                  ApplicationLoadEventArgs - container object for arguments of the Application Load event
                  CancelEventArgs - base class for events that can be canceled
                  Component - base class for all asp.net ajax objects including Control class and Behavior class
                  CultureInfo - object that can be used to provide locale specific functionality
                  Debug code - debugging and tracing functionality
                  EventArgs - used for storing event arguments
                  EventHandlerList - collection of client events for a component containing event names and handlers 
                  PropertyChangedEventArgs - contains event arguments associated with changed properties
                  StringBuilder - facilitates more efficient string concatenation

         Sys.Net - provides networking and communication support
         Sys.UI - contains set of classes for UI support
         Sys.Services - support for asp.net application services such as login/authentication
         Sys.Serialization - provides support for data serialization/Json
         Sys.WebForms - contains classes for async page loading

Shortcut Description
$addHandler Shortcut to Sys.UI.DomEvent.addHandler method
$addHandlers Shortcut to Sys.UI.DomEvent.addHandlers method
$clearHandlers Shortcut to Sys.UI.DomEvent.clearHandlers method
$create Shortcut to Sys.Component.create method
$find Shortcut to Sys.Application.findComponent method
$get Shortcut to Sys.UI.DomElement.getElementId method
$removeHandler Shortcut to System.UI.DomEvent.removeHandler method
   
   
category: Javascript

About Me

An engineer by training and a software developer at heart. My techniques and approaches meld engineering approaches with software technology.

Core to these principles is a systematic approach to the development of software with a strong lifecycle and process management emphasis through adoption of mature technologies.

Ten years designing heavy structural steel and concrete structures and 12 years in the software development profession have embedded strong project management and business knowledge in my approaches.

Subscribe to Rss Feed


Follow me on twitter @dyardy