CutomValidator to validate email address ignoring space at the end in .NET

March 19, 2009 at 8:13 am (.NET, ASP.NET, Technical) (, , )

We have compare validator in .NET to Compare the value entered by the user in an input control with the value entered in another input control, or with a constant value. Click here explore more on CompareValidator.

I had a unique requirement to validate the Email address in the two controls ignoring space at the end. I explored more and found a solution using the CustomValidator. Click here explore more on CustomValidator.

I have mentioned the code below

Added the following CustomValidator in the page:

<asp:CustomValidator ID=”CompareEmailAddress” runat=”Server” ClientValidationFunction=”CompareEmailAddress” ErrorMessage=”*” EnableClientScript = “true” ></asp:CustomValidator>

Read the rest of this entry »


Permalink 1 Comment

Configuring Multiple Sitemaps in .NET

December 7, 2007 at 1:12 pm (.NET, ASP.NET, Web Design)

Sitemaps are used to describe the structure of the site so that the site navigation controls such as menu, treeview etc can use it to display the site structure properly. Generally the owner of the site will want to display a separate navigation for anonymous and logged users. For this the menu structure will vary. In this case we can use multiple sitemaps to display the appropriate menu based on user.

For using multiple sitemaps you need to configure the sitemap in the web.config file. We will learn this through an example. Suppose we need to site that allows the logged user to buy the product and the anonymous user is allowed only to browse the product. For this we need to display buy & browse in the menu for the logged user and browse for anonymous user. To implement this we can use multiple sitemaps.

Create a new website and add the two sitemaps for this namely logged and anonymous. In the logged.sitemap add two sitemap nodes, Browse and Buy. In the anonymous.sitemap create only one sitemap node, Browse. Read the rest of this entry »

Permalink 8 Comments

Designing Menu using Sitemap and asp menu control

December 6, 2007 at 1:25 pm (.NET, ASP.NET, Web Design)

Menu can also be designed using the sitemap and the asp menu control. For this first the structure of the menu need to be designed first. Then web.sitemap for the menu is designed. web.Sitemap is an XML file that should be stored in the root directory of the website. It contains a root node <siteMapNode>. This node in turn contains multiple sitemap node for each menu item. Sitemap node has the following important attributes title, url and description.

Title : specifies the text need to be displayed on the page.

Url : Specifies the link path.

description : Specifies the tooltip text.

Part of web.sitemap is displayed below:-

<?xml version=”1.0″ encoding=”utf-8″ ?>
<siteMap xmlns=”; >
<siteMapNode url=”” title=”Tour Resources” description=”Tour Resources” >
<siteMapNode url=”” title=”Route Notes &amp; Tour info” description=”Route Notes and Tour info”>
<siteMapNode url =”../et_uk_rns.aspx” title =”Route Notes ET” description =”Route Notes ET”/>
<siteMapNode url =”../gat_rns.aspx” title =”Route Notes GAT” description =”Route Notes GAT”/>
<siteMapNode url =”../tour_summaries.aspx” title =”Tour Summaries” description =”Tour Summaries”/>
<siteMapNode url =”../tour_schedules.aspx” title =”Tour Schedules” description =”Tour Schedules”/>
<siteMapNode url=”../educationlm.aspx” title=”Educational Material” description=”Educational Material”></siteMapNode>
<siteMapNode url=”” title=”Free Time Posters” description=”Free Time Posters”>
<siteMapNode url =”../et_cityins.aspx” title =”Free Time Posters ET” description =”Free Time Posters ET”></siteMapNode>
<siteMapNode url =”../gat_cityins.aspx” title =”Free Time Posters GAT” description =”Free Time Posters GAT”></siteMapNode>
<siteMapNode url =”../cb_cityins.aspx” title =”Free Time Posters CB” description =”Free Time Posters CB”></siteMapNode>
<siteMapNode url=”../extrawts.aspx” title=”Walking Tours” description=”Walking Tours”></siteMapNode>
<siteMapNode url=”” title=”TD Travel” description=”TD Travel”>
<siteMapNode url =”../tdovernight.aspx” title =”TD Overnights” description =”TD Overnights”></siteMapNode>
<siteMapNode url =”../tdflights.aspx” title =”TD Flights” description =”TD Flights”></siteMapNode>

Then in the page where the menu need to be displayed, we need to use asp SiteMapDataSource control. Then we can use asp menu control and point the DatasourceId to the above SiteMapDataSource.

Sample Code:-

<asp:Menu DataSourceID=”SiteMapDataSource1″ ID=”Menu1″ runat=”server” BackColor=”#FFFFFF” BorderColor=”#F57F2C” BorderWidth=”1px” DynamicHorizontalOffset=”2″ StaticSubMenuIndent=”10px” >
<DynamicMenuStyle BackColor=”White” BorderColor=”#F57F2C” BorderWidth=”1px” />
<StaticMenuItemStyle BorderColor=”#F57F2C” BorderWidth=”1px” HorizontalPadding=”5px” VerticalPadding=”2px” />
<DynamicMenuItemStyle BorderColor=”#F57F2C” BorderWidth=”1px” HorizontalPadding=”5px” VerticalPadding=”2px” Font-Bold = “true” Font-Italic = “true” Font-Names = “verdana” Font-Size = “small” />
<%– <StaticSelectedStyle BackColor=”#F57F2C” BorderColor=”#F57F2C” BorderWidth=”1px” ForeColor=”White” />
<DynamicSelectedStyle BackColor=”#F57F2C” BorderColor=”#F57F2C” BorderWidth=”1px” ForeColor=”White”/> –%>
<StaticHoverStyle BackColor=”#F57F2C” BorderColor=”#F57F2C” BorderWidth=”1px” ForeColor=”White” />
<DynamicHoverStyle BackColor=”#F57F2C” ForeColor=”White”/>
<asp:SiteMapDataSource ID=”SiteMapDataSource1″ Runat=”server” ShowStartingNode=”false”/>

ShowStartingNode : It specifies that the sitemapdatasource should not display the root node in the menu.


SiteMapDataSource will get the data from web.sitemap automatically.

Permalink 21 Comments

Static menu using asp:menu control

December 6, 2007 at 12:25 pm (.NET, ASP.NET, Web Design)

Last week i explored asp menu control and found it very useful to build the menu. The asp menu control can be used to display the menu vertically or horizontally. Menu items need to be displayed under the <items> section. Each menuitem is specified using the <asp:menuitem> tag. Multiple level menus can be easily designed using the asp menu control. The code i designed for the menu is shown below:-

<asp:Menu ID=”Menu1″ Orientation = “Vertical” runat=”server” BackColor=”#FFFFFF” BorderColor=”#F57F2C” BorderWidth=”1px” DynamicHorizontalOffset=”2″ StaticSubMenuIndent=”10px” >

<DynamicMenuStyle BackColor=”White” BorderColor=”#F57F2C” BorderWidth=”1px” />

<StaticMenuItemStyle BorderColor=”#F57F2C” BorderWidth=”1px” HorizontalPadding=”5px” VerticalPadding=”2px” />

<DynamicMenuItemStyle BorderColor=”#F57F2C” BorderWidth=”1px” HorizontalPadding=”5px” VerticalPadding=”2px” Font-Bold = “true” Font-Italic = “true” Font-Names = “verdana” Font-Size = “small” />

<StaticSelectedStyle BackColor=”#F57F2C” BorderColor=”#F57F2C” BorderWidth=”1px” ForeColor=”White” />

<DynamicSelectedStyle BackColor=”#F57F2C” BorderColor=”#F57F2C” BorderWidth=”1px” ForeColor=”White”/>

<StaticHoverStyle BackColor=”#F57F2C” BorderColor=”#F57F2C” BorderWidth=”1px” ForeColor=”White” />

<DynamicHoverStyle BackColor=”#F57F2C” ForeColor=”White”/>

<asp:MenuItem Text=”Page 1″ NavigateUrl=”Page1.aspx”>
<asp:MenuItem Text=”Page 1-1″ NavigateUrl=”Page1-1.aspx”/>
<asp:MenuItem Text=”Page 1-2″ NavigateUrl=”Page1-2.aspx”/>
<asp:MenuItem Text=”Page 2″ NavigateUrl=”Page2.aspx”>
<asp:MenuItem Text=”Page 2-1″ NavigateUrl=”Page2-1.aspx”/>
<asp:MenuItem Text=”Page 2-2″ NavigateUrl=”Page2-2.aspx”/>
<asp:MenuItem Text=”Page 3″ NavigateUrl=”Page3.aspx”>
<asp:MenuItem Text=”Page 3-1″ NavigateUrl=”Page3-1.aspx”/>
<asp:MenuItem Text=”Page 3-2″ NavigateUrl=”Page3-2.aspx”/>


you can view the menu i designed below:-

Menu using aspmenu control

Important Attributes :-


Orientation attribute : The orientation attribute specifies whether the menu need to be displayed vertically or horizontally.

DynamicHorozontalOffset attribute : It specifies number of pixels to shift a dynamic menu horizontally relative to its parent menu item. The default is 0. Read the rest of this entry »

Permalink 4 Comments

Basic Event Handling in .NET

November 26, 2007 at 9:35 am (.NET, ASP.NET)


Almost all users using the GUI operating system must be knowing what is event?. Event takes place when an user interacts with the GUI(Event is not always initiated by user). The event inturn invokes methods(Event handler) to handle the event.

Various common events are:
KeyDown etc.

In addition the User can create his own events.

The simple example for the Event handling is explained here:- Read the rest of this entry »

Permalink Leave a Comment

MCTS Exam 70-536 Preparation

November 22, 2007 at 6:38 am (.NET, ASP.NET, Certification, MCTS)

I prepared the schedule to complete,

Exam 70–536: Microsoft .NET Framework 2.0 – Application Development Foundation.

I need to spend 1 hour during the weekdays and 2 and 1/2 hours during weekends to complete preparation in about 3 months. It took about an hour to prepare the schedule. To see the schedule click here

Permalink 9 Comments

MCTS Exam 70-536 Schedule

November 22, 2007 at 6:37 am (.NET, ASP.NET, Certification, MCTS)

The schedule is here:

Application Development Foundation(Exam 70 – 536):-

Chapter 1 : Framework Fundamentals(2 hrs 10 mins).
1. Using Value Types(30 Minutes).
2. Using Common Reference Types(40 Minutes).
3. Constructing Classes(40 Minutes).
4. Converting between Types(20 Minutes).

Chapter 2 : Input/Output(1 hr 5 mins).
1. Navigating the File System(20 Minutes).
2. Reading and Writing Files(20 Minutes).
3. Compressing Streams(10 Minutes).
4. Working with Isolated Storage(15 Minutes).

Chapter 3 : Searching, Modifying and Encoding Text(1 hr 15 mins).
1. Forming Regular Expressions(45 Minutes).
2. Encoding and Decoding(30 Minutes).

Chapter 4 : Collections and Generics(1 hr 45 mins).
1. Collecting Data Items(15 Minutes).
2. Working with Sequential Lists(10 Minutes).
3. Working with Dictionaries(30 Minutes).
4. Using Specialized Collections(30 Minutes).
5. Generic Collections(20 Minutes).

Chapter 5 : Serialization(1 hr 55 mins).
1. Serializing Objects(45 Minutes).
2. XML Serialization(40 Minutes).
3. Custom Serialization(30 Minutes).

Chapter 6 : Graphics(2 hr).
1. Drawing Graphics(60 Minutes).
2. Working with Images(30 Minutes).
3. Formatting Text(30 Minutes).

Chapter 7 : Threading(1 hr 40 mins).
1. Creating Threads(20 Minutes).
2. Sharing Data(40 Minutes).
3. The Asynchronous Programming Model(40 Minutes).

Chapter 8 : Application Domains and Services(1 hr 30 mins).
1. Creating Application Domains(20 Minutes).
2. Configuring Application Domains(25 Minutes).
3. Creating Windows Services(45 Minutes).

Chapter 9 : Installing and Configuring Applications(1 hr 25 mins).
1. Configuring Settings(20 Minutes).
2. Creating an Installer(25 Minutes).
3. Using the .NET Framework 2.0 Configuration Tool(15 Minutes).
4. Configuration Management(25 Minutes).

Chapter 10 : Instrumentation(1 hr 20 mins).
1. Logging Events(20 Minutes).
2. Debugging and Tracing(20 Minutes).
3. Monitoring Performance(20 Minutes).
4. Detecting Management Events(20 Minutes).

Chapter 11 : Application Security(2 hr 30 mins).
1. Understanding Code Access Security(60 Minutes).
2. Using Declarative Security to Protect Assemblies(45 Minutes).
3. Using Declarative and Imperative Security to Protect Methods(45 Minutes).

Chapter 12 : User and Data Security(2 hr 30 mins).
1. Authenticating and Authorizing Users(90 Minutes).
2. Using Access Control Lists(30 Minutes).
3. Encrypting and Decrypting Data(90 Minutes).

Chapter 13 : Interoperation(1 hr).
1. Using COM objects(20 Minutes).
2. Exposing .NET Components to COM(20 Minutes).
3. Using Unmanaged Code(20 Minutes).

Chapter 14 : Reflection(1 hr 25 mins).
1. Understanding Reflection(15 Minutes).
2. Assembly Attributes(20 Minutes).
3. Reflecting Types(25 Minutes).
4. Writing Dynamic Code(15 Minutes).
5. Creating Code at Runtime(10 Minutes).

Chapter 15 : Mail(1 hr).
1. Creating a Mail Message(30 Minutes).
2. Sending Mail(30 Minutes).

Chapter 16 : Globalization(40 mins).
1. Using Culture Information(20 Minutes).
2. Creating Custom Culture(20 Minutes).

Chapter Specified Time Estimated Time Actual Time
1 2.10 8.40 –.–
2 1.05 4.20 –.–
3 1.15 5.00 –.–
4 1.45 7.00 –.–
5 1.55 7.40 –.–
6 2.00 8.00 –.–
7 1.40 6.40 –.–
8 1.30 6.00 –.–
9 1.25 5.40 –.–
10 1.20 5.20 –.–
11 2.30 10.00 –.–
12 3.30 14.00 –.–
13 1.00 4.00 –.–
14 1.25 5.40 –.–
15 1.00 4.00 –.–
16 0.40 2.40 –.–
Total 26.10 hrs 104.40 hrs

* In addition to reading each lesson we have lab exercises which is estimated to be double the specified time for reading.

* In addition to each chapter we have a case scenario which is estimated to be as much as specified time.

* so Total preparation time = total specified time * 4 = 26.10 * 4 = 104.40 hrs.

* Staring date of preparation => 5/11/2007.

* Taking 1 hour for each weekday and 2.30 hr for each weekend day we prepare for 10 hrs each week which will take 10 weeks to complete and 1 day to complete.

* 1 week for relaxation in between

* Estimated Completion date =>

* 10 days for practice tests.

* Estimated Exam date => 02/02/2008.

Short term goals :-

Chapter 1 => 11/11/2007 8.40
Chapter 2 => 16/11/2007 4.20
Chapter 3 => 18/11/2007 5.00
Chapter 4 => 24/11/2007 7.00
Chapter 5 => 30/11/2007 7.40
Chapter 6 => 05/12/2007 8.00
Chapter 7 => 09/12/2007 6.40
Chapter 8 => 15/12/2007 6.00
Chapter 9 => 20/12/2008 5.40
Chapter 10 => 23/12/2008 5.20
Chapter 11 => 30/01/2008 10.00
Chapter 12 => 06/01/2008 14.00
Chapter 13 => 10/01/2008 4.00
Chapter 14 => 13/01/2008 5.40
Chapter 15 => 17/01/2008 4.00
Chapter 16 => 19/01/2008 2.40

All the Best !!!!!

Permalink 12 Comments


November 22, 2007 at 6:09 am (.NET, ASP.NET, Certification, MCTS)

Hi Tech Guys ,

Anybody planning to do MCTS .NET Framework 2.0 , This will be helpful to you. MCTS stands for Microsoft Certified Technology Specialist. It describes that you are specialist in a particular technology. It comes for various technologies such as,

and Many more … for all MCTS exams available see here.

I’m planning to write MCTS for .NET Framework 2.0 Web Application.It involves 2 exams namely,

  • Exam 70–536: Microsoft .NET Framework 2.0 – Application Development Foundation
  • Exam 70–528: Microsoft .NET Framework 2.0 – Web-Based Client Development

I have prepared the schedule to follow to complete Exam 70-536 in about 3 months time(1 hour preparation during weekdays and 2 1\2 hours during weekends).

Permalink 23 Comments

ReDim Statement

June 18, 2007 at 6:07 am (.NET, ASP.NET)

ReDim statement is used to resize an existing array.

Example :-

Dim names(2) as String = {“james”,”jack”,”rose”}

now if we need to add another name then we can resize the array using the ReDim statement.

ReDim names(3)

In the above example the old data in the array will be deleted when redimmed, We can use the Preserve keyword to retain the old data while ReDimming.

ReDim Preserve names(3)

What it actually does is that it copies the old data into the new array with the new size and then delete the old one thereforel it is better to avoid using ReDim statement. Instead you can use ArrayList if the exact size is not known.

Permalink Leave a Comment

How to Deploy a Web Application in ASP.NET

October 26, 2006 at 12:00 pm (ASP.NET, Web Design)

To Deploy the Web Application You have created in ASP.NET follow the steps:-

1. Open the Web application project that you want to deploy. In this case,open the SampleVB project.

 2.Select File->New Project to open the New Project Dialog box.

3. From the Project Types pane, select Setup and Deployment Projects.From the Templates pane, select Web Setup Project.

4. Change the default name of the project. In this case, change it to “SampleVBDeploy.”

5. Click OK to complete the process. The project is added in the SolutionExplorer window. Also, a File System editor window appears to the left.The editor window has two panes. The left pane displays different items. The right pane displays the content of the itemselected in the left pane.

6. Select Web Application Folder in the left pane of the File System editor window
7.Then,from the File menu select Add -> Existing Website to open the Add Existing WebSite Dialog box.Choose the Web Application that you want to Deploy(In our case its SampleVB).The Web Application will be added in the Solution Explorer Window 8.Then, from the Action menu, select Add ® Project Output to open the Add Project Output Group dialog box.

9. Verify that SampleVB is selected in the Project drop-down list. Then,select Content Files from the list.

10. Click OK. The content files of the SampleVB project are added to the solution.

11. Select Web Application Folder in the File System editor and select Properties Window from the View menu to open the Properties window.

12. Set the VirtualDirectory property to a folder, <folder name>, that would be the virtual directory on the target computer where you want to install the application. By default, this property is set to SampleVBDeploy,which is the name of the Web Setup project that youadded. In this case, set the property to DeployedApplication.

Caution The <folder name> should be a new folder name and should not already exist on the target machine. Otherwise, the contents in the folder will be overwritten.
13. In the same Properties window of the Web Application Folder, set the DefaultDocument property to Default.aspx. This property is used to set the default Web Forms page for the application.

14. Build the solution by selecting Build Solution from the Build menu.

15. After the solution is built successfully, a SampleVBDeploy.msi file is created in the Debug directory of the Web Setup project. The default path is \documents and settings\<login name>\My Documents\VisualStudioProjects\SampleVB\SampleVBDeploy\Debug\

16. Copy the SampleVBDeploy.msi file to the Web server computer (c:\inetpub\wwwroot) where you want to deploy the application.

17. Double-click the SampleVBDeploy.msi file on the target computer to run the installer.

Note To run the installer, you must have the install permissions on the computer. And, to install to the Web server, you must have IIS permissions.

After the installation is complete, you can run your application on the target computer. Todo so, start Internet Explorer and enter http://<computer name or IP Address>/DeployedApplication in the address box.

Permalink 14 Comments