Thursday, December 28, 2006

Intelligent Job Search

www.ijsearch.com allows searching for jobs from several major job portals simultaneously.

Monday, December 11, 2006

ReportViewer Control

Reporting Made Easy is a nice article about new ReportViewer Control in Visual Studio 2005.
ReportViewer Control allows to create good-looking and robust reports in ASP.NET 2.0.

Also article discusses relationships between ReportViewer Control and SQL Server 2005 Reporting Services.

Technologies: ASP.NET 2.0, C#, VB.NET, SQL Server.

Monday, November 20, 2006

Scott Guthrie on history of ASP.NET

ARCast - Scott Guthrie - the man, the myth, the legend
Scott Guthrie talks about history of developing ASP.NET, importance of prototyping, and more...

Tuesday, November 07, 2006

Inside the ASP.NET user profile mechanism

This is nice article about handling user's profile in ASP.NET 2.0:
Inside the ASP.NET user profile mechanism

The article explains:
- How to enable profile functionality in ASP.NET 2.0 application.
- How to deal with anonymous profile (anonymousIdentification), and migrate anonymous settings to registered user.
- How to handle Role-based profiles.
And more.


Keywords: C#, ASP.NET 2.0, VB.NET 2.0.

Friday, October 20, 2006

ASP.NET 2.0 Remote debugging

How to implement remote debugging in Visual Studio 2005
Remote debugging setup is greatly simplified in Visual Studio 2005. Although the DEBUG verb is still sent to the Web site to ensure that the remote process is running, all remote debugging scenarios except T-SQL debugging use the Remote Debugging Monitor (Msvsmon.exe).

Keywords: VB.NET, C#.

Wednesday, October 18, 2006

Visual Studio for Database Professionals

Scott Guthrie announces
Visual Studio for Database Professionals and other Cool Data Management Tools for .NET
"VS for Database Professionals has been getting rave reviews, and includes support for database refactorings, schema and data comparisons, database unit testing, and automated data generation."

Visual Studio .NET 2005 automatization script

Scott Allen explains how to automate SiteMap generation by VB script macro.

Technologies: ASP.NET 2.0, C#.NET, VB.NET, Web Site Map.

Thursday, October 12, 2006

Beware of HtmlEncode in GridView DataBound fields

I tried to use asp:BoundField DataFormatString="{0:d}" in asp:GridView for displaying date in short format.
Unfortunately it didn't work - I still was getting long date format, completely disregarding DataFormatString property value.

After some googling I found out that HtmlEncode needs to be set to false, in order to allow DataFormatString property work.

Read this
MSDN HtmlEncode note:
"When the HtmlEncode property is true, the value of the field is HTML encoded to its string representation before the formatting string is applied. For some objects, such as dates, you might want to control how the object is displayed with a formatting string. In those cases, you must set the HtmlEncode property to false."

Technologies: ASP.NET 2.0 ASP.NET 2005 C# VB.NET GridView control DataBound field.

Wednesday, October 04, 2006

Concurrency problem with auto-binding GridView

I always was suspicious about using ObjectDataSource as data source for ASP.NET 2.0 controls. It saves you some C# (or VB.NET) coding, but adds lots of automatically generated ASPX stuff, which is hard to maintain. Plus flexibility of the code is just not there.

Now I have another good reason not to use ObjectDataSource and automatic binding, because such approach has serious concurrency issues.
Basically if two users are using the same page simultaneously, they could delete rows which they didn’t intend to delete.

This ugly bug caused by the fact that datagrid is trying to delete rows based on row index, not based on row ID.
Read more details about the issue in: Concurrency issues with GridView by jdcrutchley.

Scott Mitchell provides a workaround (hack) to this problem, so you still can use ObjectDataSource. However the need of using hacks just kills the whole idea of using ObjecDataSource with automatic GridView binding. The advantage was to make coding easier. Now the coding with ObjecDataSource is getting more complex than straitforward approach which I like to use:
============
<asp:GridView ID="gridView" runat="server" AutoGenerateColumns="false">
  <Columns>
    <asp:TemplateField HeaderText="Delete">
      <ItemTemplate>
        <asp:LinkButton ID="Delete" runat="server" Text="Delete" OnCommand=" Delete_Command" CommandArgument='<%# Eval("RowId") /%>' />
      </ItemTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>


protected void Page_PreRender(object sender, EventArgs e)
{
  gridView.DataSource = MyBusinessClass.GetMyData();
  gridView.DataBind;
}

protected void Delete_Command(object sender, CommandEventArgs e)
{
  int rowId = int.Parse(e.CommandArgument);
  MyBusinessClass.DeleteRow(rowId);
}
============

Tuesday, September 19, 2006

Microsoft "Atlas" Control Toolkit

Microsoft "Atlas" Control Toolkit
That's a nice Atlas (Microsoft AJAX) demo.

Though I still prefer to delay starting using it, because Atlas isn't reliable solution yet.
Chances are that Atlas wouldn't work nice with IE7 :-)


Keywords: ASP.NET C# VB.NET Web UI

Saturday, August 26, 2006

CSAML: C# Application Markup Language

Enjoy this comparison of C# and XML as a programming language
---
C# Application Markup Language (CSAML): An Evolutionary Leap by Charles Petzold
Several weeks ago, Microsoft Corporation began a limited circulation of a specification and beta compiler for the new C# Application Markup Language or CSAML (sometimes pronounced "scammel"), and I’m pleased to say I find it fascinating. This merging of C# and XML is an important evolutionary leap for both standards, and represents a profound advance in the Xmlization of all textual data.
---

:-)

Keywords:
Microsoft C# XML joke parody
XML as Declarative programming language

Friday, August 25, 2006

Log4Net for ASP.NET 2.0

This article might help to setup Log4Net in ASP.NET application:
Log4Net: The Definitive(?) How-To for Those Who Have Already Experienced Some Degree of Frustration Trying to Set It Up the First-Time Around by Chad Finsterwald.

Learning from Catastrophic Database Design Failures

Great presentation about database design by Kevin Loney:
Learning from Catastrophic Database Design Failures

- There is no such thing as a harmless logical read.
- Tune the application, not the statistics.
- Time spent testing is never wasted.
- Most application performance problems are the result of deliberate design choices.
- "No production database will run in Third Normal Form."
The data must ultimately be stored in a format that is as close as possible to the users’ needs. You must never place data normalization above the business needs.
- Avoid active use of remote data.

Seriously evaluate the impact of design changes.
Test rigorously.
And ask for directions – but be careful whom you ask...

Thursday, August 17, 2006

VSS 2005 over Internet and VS.NET 2005 over HTTP

Ufff... that was a challenge: I tried to setup VSS database on Internet server and connect my machine over Internet.

The mistake was to try to connect from my DEV machine to //Server/VSS share directly.
Such solution doesn't fly: it's painfully slow and insecure.

Right approach is to properly setup VSS over HTTP.

Start with Alin Constantin's article:
Installing and configuring Microsoft Visual SourceSafe for Internet (Remote) access

But Alin's article There are still few tricks.
For example, my server (which I use for hostin VSS database) has multiple web sites (and multiple IP-addresses) associated with the server, so as a result I had to manually create VssUpload_db1 and VssDownload_db1 virtual folders.
(VSS admin creates these folder in Default web site, which doesn't work in my "multiple web sites" case.)
See:
There was a failure uploading the URL topic.


Another problem was about language mismatch between client and server VSS on different machines.
I was getting error: "The current source control operation cannot be completed.

The Visual SourceSafe Web Service returned the following error:
"The SourceSafe Web service was unable to process your request.
The selected language for non-Unicode programs in your computer does not match the one selected on the server."

This problem was discussed here:
Visual Studio Source Control and SourceSafe - selected language for non-Unicode programs
In my case I had to setup English as default language on my DEV (VSS client) machine. That's not good, but at least it works.


Unfortunately "View History" functionality doesn't work in VS.NET with Internet plug-in


Keywords:
VSS 2005 over HTTP
VS.NET 2005
Visual Source Safe 2005
Visual Studio .NET 2005
C#.NET, VB.NET

Friday, August 04, 2006

Best practises for ASP.NET web sites developers

Good article by Jeff Prosise explaining typical ASP.NET development pitfals:
Keep Sites Running Smoothly By Avoiding These 10 Common ASP.NET Pitfalls

Here's the bottom line from the article:
- Does your app use LoadControl to load user controls dynamically? If so, make sure this is done in such a way that LoadControl will work both with and without output caching.
- Are you using kernel-mode output caching and session state in the same page? If so, remove the OutputCache directive to avoid caching that page or turn kernel-mode output caching off for the entire app.
- Are you calling FormsAuthentication.RedirectFromLoginPage in your ASP.NET 1.x-based app? If so, either change the second parameter to false or modify the Expires property of outgoing persistent forms authentication cookies to a more appropriate timeout.
- Do any of your pages generate inordinate amounts of view state? If so, turn off view state for individual controls or keep it on the server.
- Does your app use SQL Server session state? If so, make sure you disable sessions in pages that don’t use sessions.
- Does your app use the ASP.NET 2.0 role manager? If so, enable role caching to increase performance.
- Does your app use custom data types as profile properties? If so, you'll avoid problems by creating custom data types that are compatible with XML serialization or by attributing the types as serializable and using the binary serializer to serialize and deserialize types.
- Does your app do database queries that take a long time to return? If so, consider whether the pages are candidates for becoming asynchronous.
- Does your ASP.NET app use client impersonation? If so, simple authentication in ASP.NET might enforce ACL-based permissions with less hassle.
- Have you profiled your app’s database activity? Examining communication between the app and database is a good first performance-tuning step.

Tuesday, August 01, 2006

Multiline HTML buttons

Here's HTML code to Multiline caption buttons:
====
 <button>multiline<br>button<br>text</button>

<input type="button" value="Carriage&#13;&#10;return&#13;&#10;separators" style="text-align:center;">
====

Actual buttons:



---
Keywords: HTML DHTML Multi-line Multy line button caption. Web Forms. IE Internet explorer FireFox Opera

Reorder multiple <select> fields in a web page

Nice article about reordering listbox fields.
User can move one or several fields at once. User can use buttons or mouse wheel.
Reorder multiple <select> fields in a web page - JavaScript

Keywords: select options reorder postback javascript jscript asp asp.net perl

Wednesday, July 05, 2006

Exception handling

This is great article by Karl Seguin about proper exception handling:
Understanding and Using Exceptions
Here are the key points:
- Don't catch exceptions unless you can actually handle them
- Do know how to rethrow exceptions properly
- Do use using or try/finally often
- Don't swallow exceptions
- Do use a global handler to help you log and display a friendly error message

---
Exception handling in .Net (some general guidelines) by Marc Brooks.
---
Keywords: ASP.NET 2.0, C#, VB.NET
Q: How could I quickly pass array from business layer (e.g. ASP.NET 2.0) to MS SQL Server 2005?

A: Pass XML to Stored Procedure.
SQL Server - No Arrays? No Problem!

1) Prepare XML string like this:
<data>
 <meta>
  <key>Key1</key>
  <value>Value1</value>
 </meta>
 <meta>
  <key>Key2</key>
  <value>Value2</value>
 </meta>
</data>
2) Pass it to Stored Procedure:
command.Parameters.Add("@Tags", SqlDbType.Xml).Value = NameValueToXml(post.Tags)
3) Stored Procedure:
CREATE PROCEDURE SavePost
(
...
@Tags XML
)
AS
...
INSERT INTO Xxx
SELECT ItemData.row.value('key[1]', 'varchar(200)'),
ItemData.row.value('value[1]', 'varchar(200)')
FROM @Tags.nodes('/data/meta') ItemData(row)
Q: How could I quickly pass array from business layer (e.g. ASP.NET 2.0) to MS SQL Server 2005?
SQL Server - No Arrays? No Problem!

1) Prepare XML string like this:
<data>
 <meta>
  <key>Key1</key>
  <value>Value1</value>
 </meta>
 <meta>
  <key>Key2</key>
  <value>Value2</value>
 </meta>
</data>
2) Pass it to Stored Procedure:
command.Parameters.Add("@Tags", SqlDbType.Xml).Value = NameValueToXml(post.Tags)
3) Stored Procedure:
CREATE PROCEDURE SavePost
(
...
@Tags XML
)
AS
...
INSERT INTO Xxx
SELECT ItemData.row.value('key[1]', 'varchar(200)'),
ItemData.row.value('value[1]', 'varchar(200)')
FROM @Tags.nodes('/data/meta') ItemData(row)

ASP.NET 2.0 Global Event handling: HttpModules

Global.asax? Use HttpModules Instead! by Karl Seguin

namespace Fuel.Web
{
public class ErrorModule : IHttpModule
.....
}

Web.config:
<httpModules>
<add name="ErrorModule" type="Fuel.Web.ErrorModule, Fuel.Web" />
</httpModules>

Tuesday, June 27, 2006

Text Legibility: Using 120 DPI Fonts on High Resolution Displays

You have high-resolution monitor and hate this small fonts? This article will help you:
Using 120 DPI Fonts on High Resolution Displays

Interactive design: Fitts law

This great and fun-to-read article explains fundamental law of interactive UI design.

A Quiz designed to Give You Fitts
"Fitts' Law: The time to acquire a target is a function of the distance to and size of the target."
.....
"Microsofts general cluelessness has never been so amply displayed, however, as it is in Microsoft Visual Studio, which has a menu bar at the top of the screen with a one-pixel barrier between the screentop and the menu. Talk about snatching defeat from the jaws of victory."

Interactive design: Fitts law

This great and fun-to-read article explains fundamental law of interactive UI design.

A Quiz designed to Give You Fitts
"Fitts' Law: The time to acquire a target is a function of the distance to and size of the target."
.....
"Microsofts general cluelessness has never been so amply displayed, however, as it is in Microsoft Visual Studio, which has a menu bar at the top of the screen with a one-pixel barrier between the screentop and the menu. Talk about snatching defeat from the jaws of victory."

Tuesday, June 20, 2006

ASP.NET 2.0 Web site compilation and deployment options

Good article about ASP.NET 2.0 web site deployment options: both scripts and UI:
Precompiling the Site

This is the command you could use to pre-compile everything (this should all be entered on one line):
aspnet_compiler.exe -p c:\Projects\ASP.NET\TheBeerHouse\TBH_Web -v /TheBeerHouse c:\Deployment\TheBeerHouse

In the case of deploying to your own sites, it’s simpler to pre-compile only the source code files but not the markup files. To do this, just add the -u switch (which stands for updateable) to the command line, as follows:
aspnet_compiler.exe -p c:\Projects\ASP.NET\TheBeerHouse\TBH_Web -v /TheBeerHouse -u c:\Deployment\TheBeerHouse

Compile with fixed DLL names:
aspnet_compiler.exe -p c:\Projects\ASP.NET\TheBeerHouse\TBH_Web -v /TheBeerHouse -u -fixednames c:\Deployment\TheBeerHouse

Download Visual Studio 2005 Web Deployment Projects

Merge all ASP.NET DLLs into one:
C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\aspnet_merge.exe c:\Deployment\TheBeerHouse

---
Keywords: ASP.NET 2.0, C#, VB.NET 2.0, WebForms, Web Forms, Deployment

Friday, June 02, 2006

XML -> CSV XSL Transformation

CSV - comma separated values format (supported by Excel).
Handling quotes in XML->>CSV XSLT
First trick is to save the " and "" inside a variable, second trick is to use a recursive template.


Handling quotes, commas and line-breaks in XML->>CSV XSLT

In a CSV file, if a field value contains a comma or a linefeed or a quote, then
it must be enclosed in quotes.
Also, if a field value contains quotes, then an extra quote must be inserted in front of each quote.



My implementation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
<xsl:for-each select="Table">
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column1"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column2"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column3"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>


<xsl:template name="DisplayCSV">
<xsl:param name="field"/>

<xsl:variable name="linefeed">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains( $field, '&quot;' )">
<!-- Field contains a quote. We must enclose this field in quotes,
and we must escape each of the quotes in the field value.
-->
<xsl:text>"</xsl:text>

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="normalize-space($field)"/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>

<xsl:text>"</xsl:text>
</xsl:when>

<xsl:when test="contains( $field, ',' ) or
contains( $field, $linefeed )" >
<!-- Field contains a comma and/or a linefeed.
We must enclose this field in quotes.
-->
<xsl:text>"</xsl:text>
<xsl:value-of select="normalize-space($field)" />
<xsl:text>"</xsl:text>
</xsl:when>

<xsl:otherwise>
<!-- No need to enclose this field in quotes.
-->
<xsl:value-of select="normalize-space($field)" />
</xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

XML -> CSV -> HTML conversion

CSV - comma separated values format (supported by Excel).
Handling quotes in XML->>CSV XSLT
First trick is to save the " and "" inside a variable, second trick is to use a recursive template.


Handling quotes, commas and line-breaks in XML->>CSV XSLT

In a CSV file, if a field value contains a comma or a linefeed or a quote, then
it must be enclosed in quotes.
Also, if a field value contains quotes, then an extra quote must be inserted in front of each quote.



My implementation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
<xsl:for-each select="Table">
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column1"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column2"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column3"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>


<xsl:template name="DisplayCSV">
<xsl:param name="field"/>

<xsl:variable name="linefeed">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains( $field, '&quot;' )">
<!-- Field contains a quote. We must enclose this field in quotes,
and we must escape each of the quotes in the field value.
-->
<xsl:text>"</xsl:text>

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="normalize-space($field)"/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>

<xsl:text>"</xsl:text>
</xsl:when>

<xsl:when test="contains( $field, ',' ) or
contains( $field, $linefeed )" >
<!-- Field contains a comma and/or a linefeed.
We must enclose this field in quotes.
-->
<xsl:text>"</xsl:text>
<xsl:value-of select="normalize-space($field)" />
<xsl:text>"</xsl:text>
</xsl:when>

<xsl:otherwise>
<!-- No need to enclose this field in quotes.
-->
<xsl:value-of select="normalize-space($field)" />
</xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
Handling quotes in XML->>CSV XSLT
First trick is to save the " and "" inside a variable, second trick is to use a recursive template.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />

<xsl:template match="/">

<xsl:apply-templates select="." mode="x"/>

</xsl:template>
<xsl:template match="text()" mode="x">

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>

<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="."/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>




Handling quotes, commas and line-breaks in XML->>CSV XSLT


The solutions presented so far assume that
the field values will not contain any commas,
linefeeds or quotes.

In a CSV file, if a field value contains
a comma or a linefeed or a quote, then
it must be enclosed in quotes.

Also, if a field value contains quotes,
then an extra quote must be inserted in
front of each quote.



My implementation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
Alternate Agent Number,Previous Agent Alpha,Agency Head Office
<xsl:for-each select="ODBCDBConnect">
<xsl:for-each select="Table">
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="ALKALTNUM"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="ALKPRVAGTA"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="ADAGHD"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


<xsl:template name="DisplayCSV">
<xsl:param name="field"/>

<xsl:variable name="linefeed">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains( $field, '&quot;' )">
<!-- Field contains a quote. We must enclose this field in quotes,
and we must escape each of the quotes in the field value.
-->
<xsl:text>"</xsl:text>

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="normalize-space($field)"/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>

<xsl:text>"</xsl:text>
</xsl:when>

<xsl:when test="contains( $field, ',' ) or
contains( $field, $linefeed )" >
<!-- Field contains a comma and/or a linefeed.
We must enclose this field in quotes.
-->
<xsl:text>"</xsl:text>
<xsl:value-of select="normalize-space($field)" />
<xsl:text>"</xsl:text>
</xsl:when>

<xsl:otherwise>
<!-- No need to enclose this field in quotes.
-->
<xsl:value-of select="normalize-space($field)" />
</xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

Tuesday, May 30, 2006

Checking All CheckBoxes in a GridView

Checking All CheckBoxes in a GridView

Here's the part which shows how to implement client-side JavaScript checking/unchecking
C#:
protected void Page_Load(object sender, System.EventArgs e)
{
// DataBind GridView here
//...

'On every page visit we need to build up the CheckBoxIDs array
foreach(GridViewRow row in grid.Rows)
{
//Get a programmatic reference to the CheckBox control
CheckBox chk = (CheckBox)row.FindControl("chk");
ClientScript.RegisterArrayDeclaration("CheckBoxIDs", string.Concat("'", chk.ClientID, "'"));
}
}

JavaScript:
<script type="text/javascript">
function ChangeCheckBoxState(id, checkState)
{
var cb = document.getElementById(id);
if (cb != null)
cb.checked = checkState;
}

function ChangeAllCheckBoxStates(checkState)
{
// Toggles through all of the checkboxes defined in the CheckBoxIDs array
// and updates their value to the checkState input parameter
if (CheckBoxIDs != null)
{
for (var i = 0; i < CheckBoxIDs.length; i++)
ChangeCheckBoxState(CheckBoxIDs[i], checkState);
}
}
</script>

...

<input type="button" value="Check All" onclick="ChangeAllCheckBoxStates(true);" />
 
<input type="button" value="Uncheck All" onclick="ChangeAllCheckBoxStates(false);" />

Tuesday, May 02, 2006

How to use DefaultFocus and DefaultButton properties with Master page

Want to set default button (submit) and default input control in ASP.NET 2.0?
No problem - use Page.Form.DefaultFocus and Page.Form.DefaultButton properties.

But what if you work with Master Page or trying to implement User Control (Server Control)?

Short answer:
=====
Page.Form.DefaultFocus = TextBox1.UniqueID;
Page.Form.DefaultButton = Button1.UniqueID;
=====

Longer answer is here:
How do I set DefaultFocus or DefaultButton

Keywords: ASP.NET 2.0, C# 2.0, MSDN2

Great ASP.NET 2.0 Tutorial Videos Online

Microsoft & Scott Guthrie's team published ASP.NET 2.0 Tutorial Videos:
Great ASP.NET 2.0 Tutorial Videos Online
The videos are short (~15 minutes each), easy to grasp and implement/repeat, and are very functional.
Enjoy!

Sunday, April 30, 2006

Google's Secret Weapon

Nice article about recruiters struggling and competing in hiring talented software engineers:
Google's Secret Weapon

The Five Essential Phone Screen Questions

Steve Yegge gives his recommendations how to screen (pre-interview) developers:
The Five Essential Phone Screen Questions
In my opinion, his recommendations would work nice if questions would be asked during phone interview (not screening). + obviously these questions are shaped for Unix developers. + these questions are for at least mid-level developers and higher (seniors).
I think that Juniors have be able to answer all these "Five Essential Questions".

Friday, April 28, 2006

Scott Guthrie blog

Scott Guthrie is a Program Manager of ASP.NET team at Microsoft:
ScottGu's Blog
This blog is full of ASP.NET 2.0 code examples, demos, tips, ideas, links to other blogs and articles ... --- very interesting and very fresh ASP.NET stuff.

VB.NET, C# 2.0.

ASP.NET debugging blog

Tess is bloggin about debuggin ASP.NET applications:
If broken it is, fix it you should
Compilation, web.config debugging configuration, deploying DLLs, and more...

Monday, April 03, 2006

How to: Localize Site-Map Data

If you want to localize your Site Map you may check this MSDN article:
How to: Localize Site-Map Data

ASP.NET 2.0
ASP.NET 2005

Tuesday, March 28, 2006

How to access Private Protected methods in .NET

Sometimes we want to get access to protected or even private methods and properties.
For example, I needed it because I tried to reuse standard Microsoft functionality in my feature.
Sometimes protected and private methods are more convenient building blocks than public methods...
Anyway, here we are:
How to Test Private and Protected methods in .NET

C#, C#.NET

Monday, February 20, 2006

How to get rewarded for incompetence

How to get rewarded for incompetence
.....
Steve studied the business issues and recruited key personnel from the AP department to help identify information requirements and develop a rough design of the solution.
.....
Bob took a different approach. Focused on fast results, he set part of his group to building a core AR database, while a second set of programmers created basic input screens and sample outputs. In no time, Bob had something to show the boss, who was suitably impressed.
.....

Wednesday, February 15, 2006

Paging through lots of data with MS SQL Server 2005 and ASP.NET 2.0

This link explains how MS SQL Server 2005 supports paging in GridView (web control in ASP.NET 2.0) through "ROW_NUMBER() OVER (...)" function:

Paging through lots of data efficiently with ASP.NET 2.0

This is another article on the "SQL Pager" topic:
Returning Ranked Results with Microsoft SQL Server 2005
You can find here some nice stuff about Ranking SELECT's resultset.

Tuesday, February 07, 2006

Developing Custom ASP.NET Server Controls

Developing Custom ASP.NET Server Controls
This section describes how to develop ASP.NET server controls. It contains a walkthrough that provides an overview of authoring a custom server control and it provides code examples that illustrate different control authoring tasks such as rendering, defining properties, managing state, and creating composite controls.

Followers

Blog Archive

About Me

My photo
Email me: blog@postjobfree.com