The techie in me RSS 2.0
 Monday, February 08, 2010

I had lot of trouble in my last project due the html body onload event. The aspx pages were relying lot on this event ( I agree its not the best way, but we don't have the budget and time for to rebuild the entire site). These sites were AJAXyfied recently using Telerik RadControls, and were not working in FireFox. I must admin Telerik controls are really good, its makes your job very easy in AJAX world. Though I don't like their quarterly release idea. YES, they release a new version every quarter...

So the problem in AJAX is, the page can be loaded asynchronously, so when the onload event on the body is fired the controls may not be ready, so you get null exceptions.

The best way I found is to use the built in ‘pageLoad()’ method(this is a reserved method). This will be called once all AJAX load events are finished. Remember you can use this only in AJAX pages. Also this is consistent in different browsers. (If you are going with FireFox you have to use window.load=function() instead onload=function())

Coding is fun

-Rujith

Monday, February 08, 2010 12:32:00 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding
 Sunday, February 07, 2010

Maximum request length matters when you want to allow upload/download of large files.

This is one of the major change in IIS7. In previous version the default is 4MB, in IIS7 its 28.6MB. So when you deploy your ASP.NET application you will see that it will work for files larger than 4MB, but will give as soon as you cross the 28MB.

In IIS 7, the attribute has been changed to maxAllowedContentLength and it has to appear in <system.webServer> section (as for all IIS 7 settings). The complete attribute will look something like this…

<system.webServer>
<
security > <requestFiltering> <requestLimits maxAllowedContentLength="3072000000" /> </requestFiltering> </security>

 

Sunday, February 07, 2010 12:18:00 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding | WCF
 Sunday, January 10, 2010

When you are working with Active Directory the following may be useful,

Import and export directory objects – CSVDE & LDIFDE
ex: from the command prompt try CSVDE -f C:\Exportfile.csv
more help is available in this KB article.

Another useful utility while working with Active directory and LDAP(Light Weight Directory Access Protocol) is ADSI Edit (adsiedit.msc). Nice link if you want to know in detail.

Also found this interesting link with attributes and its description for AD Users. see here. And check this script to list all User object attributes in active directory schema.

Sunday, January 10, 2010 10:23:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding
 Friday, December 04, 2009

ADO.NET data provider for Oracle is dying. ADO.NET team has decided to kill(deprecate) it in .NET 4.0. How sad isn’t it? Read more about the story on ADO.NET team blog

Though sometimes I feel its unnecessary to have a duplicate copy of Oracle data provider. Most of the people use ODP.NET or some other third party client. Nice comparison here (and that is why people don’t use .NET Oracle client :))

One very bad thing I noticed about these providers is both of them need Oracle client installed. For the MS provider(System.Data.OracleClient) the minimum requirement is Oracle 8i Release 3 (8.1.7) Client or later. Check the requirement in detail here System Requirements (Oracle).
For the ODP.NET Oracle client version 9.2 or later.

Its not always possible to install a large application like Oracle client in some scenario, so there is an alternative without installing the Oracle client, use Oracle Database Instant Client. Just put Oracle Instant Client in the same folder as your executable file.

-Rujith

Friday, December 04, 2009 3:58:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding | Database
 Saturday, January 24, 2009

We all know that there are lot of chart tools for .NET, but most of the good ones are not free.... now check this out, finally some of them from MS itself...

Saturday, January 24, 2009 9:10:34 PM (GMT Standard Time, UTC+00:00)  #    Comments [2] -
Coding
 Tuesday, December 30, 2008

Found some nice guy sharing C# and VB.NET coding standards... might be useful when you dont have enough time(usually never!) to create coding standards from scratch.

check out Clint Edmonson's blog here

 

Tuesday, December 30, 2008 11:16:37 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding
 Saturday, May 17, 2008

If you have worked with strongly typed dataset, it is very likely that you must have faced this annoying exception regularly. The error message will be something like this.

The value for column \'ColumnName\' in table \'TableName\' is DBNull.

With exception type : System.Data.StrongTypingException

Well that's a typical message ain't it ? But interesting part is, if you see the property code in the dataset class it will similar to

get {
    try {
        return ((global::System.String)(this[this.tableName.Column]));
    }
    catch (global::System.InvalidCastException e) {
        throw new global::System.Data.StrongTypingException("The value for column \'Column\' 
                                 in table \'TableName\' is DBNull.", e);
    }
}
set {
    this[this.TableName.Column] = value;
}

Now from the code you can see that, if you are thinking of comparing the field with Dbnull or null or some value still it will give the error. It is a InvalidCast exception.

There is a simple method to solve this issue, when you use the xsd.exe(or VS IDE) to generate the dataset class give a value for the 'null value'

This is how you do it.

1. Add codegen namespace in the scheme

In the xsd file(schema) add the below line to add the namespace immediately after targetnamespace

xmlns:codegen="urn:schemas-microsoft-com:xml-msprop

2. Add the 'null value' to the elements you want to protect from this error.

for ex :

<xs:element name="Column1" codegen:nullValue="-1" type="xs:string" minOccurs="0" />

The bold attribute sets the nullvalue.

 

Thats it, then generate your typed dataset, and you will no longer have the weird exception.

If you really dont want to touch the xsd, there is another way of getting rid of this, the dataset class gives a method 'IsColumnNull', use this method in your code to check if its null :)

The above information is extracted from MS KB article

 

Keep strong typing :)

-Rujith

Saturday, May 17, 2008 1:21:57 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding
About me
Name : Rujith Anand
Occupation : Eating, drinking, sleeping and Yes ofcourse coding.
Location : Reading, UK
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogs I read
Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Rujith Anand

Statistics
Follow me on Twitter
All Content © 2010, Rujith Anand