0
Comments

ASP.NET MVC Tips: 301 Redirect non-www versions of URL to www. by shahed

Search Engine Optimization guides, recommends to have one version of a URL of the same content. Search engines may pickup www and non-www versions of URL as 2 separate URLs, i.e. http://xyz.com/page1 may be considered different to http://www.xyz.com/page1...
0
Comments

ASP.NET MVC Tips: Form POST, TryUpdateModel, unit test, Moq by shahed

Recently I have started playing with the Moq (pronounced "Mock-you" or just "Mock") a Mocking Library for .NET Developers, that takes full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features. Here in this post I...
0
Comments

ASP.NET MVC tips: Routing Engine to aid SEO / 301 Redirect / Tracking by shahed

Routing Library resides in the System.Web.Routing Namespace of the .NET Framework 3.5, which provides us the flexibility to use URLs that has no mapping to a physical file. This means ASP.NET MVC framework provides flexible URL mapping engine and enables...
0
Comments

ASP.NET tips: Display resultset from Multiple DataTable by shahed

I normally do not use DataSet and prefer Objects instead generated by the ORM frameworks, but recently I had to produce a ASP.NET page that displayed a list of records from multiple DataTables. Lets look at a similar example. Lets assume we consume this...
0
Comments

ASP.NET tips: CustomBase class with Generic Class by shahed

All our ASP.NET pages must derive from System.Web.UI.Page class, but we can take the advantage of inheritance and create a Custom Base Class to manage Security, Session, Error Handling and other repetitive custom codes elegantly. We normally go and create...
0
Comments

Microsoft Chart Controls for ASP.NET and Windows Forms by shahed

Now Microsoft Chart controls Add-on for Microsoft Visual Studio 2008 can be used for charting needs. Prerequisite: Microsoft Visual Studio 2008 SP1 and Microsoft Chart Controls for Microsoft .NET Framework 3.5 . For sample Environment for Microsoft Chart...
0
Comments

Reflection Tips on Nested Classes: Use (+) plus instead of (.) dot with Assembly.GetType by shahed

Lets say we want to use reflection to generate a mock test case for this following Nested Class ClientAddress . When we load an assembly from a disk dynamically, we can use GetType to look up a type defined in the assembly. Example: Assembly assembly...
2
Comments

ASP.NET Tips: DropDownList.ClearSelection() to avoid "Cannot have multiple items selected in DropDownList" by shahed

Problem I was facing the following Exception when I was programmatically assigning Selected Value of a DropDownList with the following piece of code. ListItem item = DropDownListTest.Items.FindByValue("Test"); if (item != null) item.Selected...
0
Comments

Reflection Tips: Generate Mock objects for Test Cases. by shahed

Filling up Mock objects with random data is possibly one of the most time consuming and boring chapter of writing test cases. Let say we have the following classes and we want to write some mock objects. Mock Object Code Example private Client GetMockClient...
0
Comments

C# Reflection Tips: Data transformation using Reflection by shahed

.NET Reflection can be quite handy to transform one object to another, and specially when the target data structure varies a lot. Lets say, a "source party" has a stable Source data structure. But different clients have different requirement...
0
Comments

ASP.NET tips, Making Custom Validators work in Partial Rendering mode. by shahed

Introduction There are many situations where we need to identify if partial rendering is supported in a page, especially when a control uses javascript, to get the control work in partial rendering mode, the script needs to be registered using a ScriptManager...
1
Comments

ASP.NET tips: Golden rules for Dynamic Controls. by shahed

1. Make sure your dynamic controls are Loaded on every postback. Lets play with a very simple example, ASPX <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <body>...
0
Comments

C# 3.0 tips, Automatic Property by shahed

Declaring a property in C# 3.0 is super easy and super short. public class Student { public string Name { get; set; } } yes that's it, the framework will take care of the rest, the private variables will be automatically created and the getter and...
0
Comments

System.Net.WebClient().DownloadString(url) for Web Scrapeing by shahed

WebRequest is the abstract base class for the .NET Framework's request/response model for accessing data from the Internet. To get content of a website, in .NET 1.0. we used to use WebRequest, which is good and also works asynchronously. public static...
0
Comments

Project SOAK winner of 2008 Imagine Cup Australia. by shahed

The theme of this year’s Imagine Cup is " Imagine a world where technology enables a sustainable environment ." It had been a great honorary for me to take part as one the Judges of the 2008 Imagine Cup Australia. All the teams worked real hard...
0
Comments

ASP.NET Bug, Multi View control do not save ViewState, of dynamically added controls by shahed

Couple of days back me and my colleague, we discovered an issue with the ASP.NET Multi View Control. We were surprised to see that it do not add ViewState, of the dynamically added controls, of the Inactive Tabs. ASP.NET 2.0 <asp:MultiView ID="MultiView1"...
0
Comments

ASP.NET Tips: Using Image as Embedded Resource for ASP.NET CustomControl by shahed

Problem I started writing an ASP.NET Custom Server Control, where I wanted an Image to be Embedded Resource of the Assembly itself, so that, I do not need to ship the images separately, but surprisingly it did not work straightway for me. The following...
0
Comments

DataTable to JSON and ToJSON() Extension by shahed

Very recently I wrote an application where I had to deal with DataSet from a Web Service. Please note, I have no control on the Web Service and I ended up writing a small function which converts DataTable to JSON. I understand I haven't gain anything...
0
Comments

Visual Studio 2005 Debugging in Vista by shahed

Problem : I was trying to debug in Visual Studio 2005 in my new machine which came with Vista Home Premium. Surprisingly I found that none of the break points are touched and I cannot debug. I tried giving all types of permission to the folder but no...
0
Comments

Javascript Tips: Carefully use "this" when writing classes, else you may cause memory leak. by shahed

Lets say we want to declare a class in Javascript, which is equivalent to the following C# class. public class Student { public string FirstName = "" ; public string LastName = "" ; public Student( string firstname, string lastname...
More Posts Next page »
Powered by Community Server (Commercial Edition), by Telligent Systems