Saturday, November 15, 2008

Tracking User Activity in Web site with ASP.Net C#.Net

Reason to Track User Activity:

Now a days every small business is listed over the Internet. Every business wants to expand and get more business from the World Market. Also some users want to generate revenue from the public ads like Google Adsense.

To obtain higher business a web site owner needs to understand visitor behavior. Now to understand the visitor behavior a developer need to log all the activity of a visitor. From which source a user has reached to web site. If the user has came from a search engine then on which keyword he has searched. How user navigate to other page? How much time a user spend on the web page? How many page a user visit in a single visit?

After analyzing above all data a developer can decide how to keep user visiting web site? Which section of the web site have most visit? Where to improve in the user interested content?

Tools for Tracking User Activity:

To track the user activity there are many Online tools are available like Google Analytics or MyBlogLog. Google Analytics is a free user tracking tool provided by Google. With Google Analytics you can analyze your visit and monitor visit from different country, visit from different sources, visit on different keywords. You can also monitor entering and exiting page. MyBlogLog is providing free service but it is limited. If you want a full service you need to upgrade to MyBlogLog Pro which is paid.

Thursday, November 6, 2008

Customizing and Personalizing a Web Application with ASP.Net C#

ASP.Net 2.0 provides the ability to customize and personalize Web-based applications by using four techniques. These techniques include master pages, themes, user profiles, and Web parts. The following describes briefly about each of these four techniques:
  1. Master Page: A master page is a technique that customizes and personalizes a Web application. It defines the look, feel and the standard behavior that should be for each Web page in the application. it creates a consistent layout for all Web pages in the application. A master page consists of two parts: a master page and one or more content pages, which have been described in the following manner:
    • Master Page: A master page is an ASP.Net file with a .master extension. It contains the layout that includes text, HTML, and server controls. It is identified by the @Master directive that replaces the @Page directive. The @Master directive contains all HTML elements such as <html>, <head>, and <form> for a Web page. The @master directive syntax is as follows:

      <%@ Master Language="C# %>

      It is inherited from the MasterPage class and contains one or more ContentPlaceHolder controls. The following code snippet displays a master page:

      <%@ Master Language="C#" %> 
          <head runat="server"> 
               <title>Master Page</title> 
              <form id="MyWebForm1" runat="server"> 
              <asp:ContentPlaceHolder ID="FrontPage" runat="server" /> 
              <asp:ContentPlaceHolder ID="FootNote" runat="server" /> 
    • Content Page: A content page is a standard Web page with an .aspx file extension. It defines the ContentPlaceHolder controls in a master page and is bound to it. It is used as the MasterPageFile attribute in the @Page directive. For example:

      <%@ Page Language="C#" MasterPageFile="MyMasterPage.master" %>

      The following code snippet displays a content page:

      <%@ Page Language="C#" MasterPageFile="MyMasterPage.master" Title="FirstContentPage" %> 
      <asp:Content ID="WebContent1" ContentPlaceHolderID="FrontPage" runat="server"> 
           FrontPage Content. </asp:Content> 
      <asp:Content ID="WebContent2" ContentPlaceHolderID="FootNote" runat="server"> 
           FootNote Content. </asp:Content>

      Note: When a user requests content pages, ASP.Net merges the contents of the content pages with the master page being created for the specified Web application.
  2. Themes: A theme is another technique of customizing and personalizing a Web application. It is a collection of ASP.Net property settings such as background color, font size and style, and foreground color. These property settings define the look and appearance of Web pages and controls. These looks are applied consistently across all the pages in a Web application. A theme consists of a set of elements that include skins, cascading style sheets (CSS), images, and other resources. It is defined in special directories in a user's Web site or on a Web server. The following describes briefly about each element of a theme:

    • Skins: A skin is an element of the theme and is stored in the Theme folder with a .skin file extension. It contains property settings for server controls such as Button, Label, TextBox and Calendar controls. These property settings are defined as part of the theme applied to an application. A skin file contains more than one control skins are resembles as control markups. Skins can be defined in a separate file for each server control. Therefore, all the skins for a particular theme are defined in one file. There are two types of control skins, default skins and named skins.

      When a theme is applied on a Web application a default skin is automatically applied to all controls of the same type. However, a default skin does not have a SkinID attribute. On the other hand, a named skin has to be explicitly applied to a control by setting the control's SkinID property. One advantage of the named skin is that a user can set different skins for different instances of the same control type.
    • Cascading Style Sheets (CSS): A cascading style sheet (CSS) is an element of a theme applied to a Web application. It stores all formatting style information for the application in a single file with .css extension in the Theme folder. It adds different styles such as fonts, colors, and spacing between text lines to contents on a Web page. By default, it automatically applies to all Web pages of an application. By attaching CSS enhances the presentation of all the Web pages.
    • Images and Resources: A theme also includes images and other resources such as script files or sound files as an element. For example, a specific image as part of a theme can represent the expand button and the collapse button in a Web page. A resource file can be either stored in a subfolder of the theme or outside the theme folder. If a resource file is stored outside the theme folder, a tilde '~' syntax is used to find the images automatically by the application.
  3. User Profiles: A user profile is another technique that can customize and personalize a Web application. ASP.Net provides a user's experience with a Web site by defining and using profile properties on the Web site. When profile properties are defined, it becomes easy to track user information, as the individual instances of the profile properties are automatically associated with each user. Each profile data value is stored in a data store from where the profile property for a user can be retrieved. By default, a profile information is stored in a SQL Server database by using the SqlProfileProvider class.

    Profiles can be used with either authenticated or non-authenticated users. Profiles are automatically enabled for authenticated users when a Web application required user authentication. For non-authenticated users, ASP.Net profiles have to be explicitly enabled in the Web.config file of the application. The <anonymousIdentification> element to the <system.web> section is added to the Web.config file and the enabled attributes are set to true. When the anonymous profiles are enabled, a unique identification is created for each user and the information is tracked with a cookie. A user profile can also work without any cookie by storing unique identifiers of each user in the URL of the Web page request. But, the drawback is that the profile is lost when a user's session is expired.
  4. Web Parts: A Web part is a technique of customizing and personalizing a Web application. It is an integrated set of controls to enable a user to modify the contents, appearances, and behavior of all Web pages directly from a Web browser. the modified Web pages and controls as well as the settings can be easily saved across Web browser sessions for the future user requests. This feature can be called as the personalization.

    A Web part can be used for a list of news articles related to a specific organization, a blog site, a calendar, and search box. It is also used for a list of Web site links, graphs showing stock market reports, local weather reports, and images taken from picture galleries. A standard or a custom control can be a Web part, which does not require writing code when using it as a Web part. A Web Part consists of three main sections. They include personalization, user interface (UI) structural components, and actual Web parts user interface controls.

Friday, October 31, 2008

Creating and Managing Database Objects using T-SQL Statements in SQL Server

Database: A database comprises information in structured and organized form that can easily be accessed and manipulated. According to the needs of a Web site, the database can be large or small in size. A database can be stored on a single PC or on a collection of high-powered database servers depending upon the size. When a database is stored on a collection of servers, it is known as a distributed database. It is a collection of relevant data that is interconnected and organized systematically so that its contents can easily be accessed, managed, and updated electronically.

The syntax for creating a database is as follows.

CREATE DATABASE database_name
Two files whose extensions are .mdf and .ldf are responsible for creating a database. The .mdf file is a data file, where .ldf is log file.
Database Objects: A database consists of various types of objects that are used to manage a database. The database objects are used to store data. Various properties of these database objects are used to sort, index and search data. The database objects are as follows:
  • Table
  • View
  • Index
  • Constraint
Table: A table is the basic unit of data storage in a SQL Server database. It is composed of columns and rows. A column is vertical space in a database table, which represents a particular domain of data. A row is a collection of data in columns corresponding to a single record. A table can be created in a database at any time, even while users are using the database. While creating a table, its size need not be specified. It is ultimately determined by the amount of space allocated to the database as a whole.
The syntax for creating a table is as follows:
CREATE TABLE table_name
     column1 datatype NULL | NOT NULL
     column2 datatype NULL | NOT NULL
     column3 datatype NULL | NOT NULL
     column4 datatype NULL | NOT NULL
     column5 datatype NULL | NOT NULL
Modifications can be made to an existing table by using the ALTER Table statement. In order to alter the column settings of a table, the following syntax is used:
ALTER TABLE table_name
    ALTER COLUMN column_name
        CONSTRAINT constraint_name

In order to modify collation settings, the following syntax is used:

ALTER TABLE table_name
    COLLATE collation_name

The DELETE statement is used to delete records from a table or a view. The syntax for using the DELETE statement  is as follows:

DELETE * FROM table_name

The above syntax will delete all the records from a table.

DELETE FROM table_name WHERE column_name=value

The above syntax will delete records based on the search criteria.

In order to delete a table, the DROP TABLE statement is used. The syntax for deleting a table is as follows:

DROP TABLE table_name

View: A view can be thought of as a virtual table. Data accessible through a view is not stored in the database as a distinct object. A View is created by defining a SELECT statement. The result set of the SLECT statement from the virtual table. A user can use this virtual table by referencing the view name in SQL statements in the same way a table is referenced.

The syntax for creating a view is as follows:

CREATE VIEW view_name AS
SELECT columns
FROM table_name


The WITH CHECK OPTION is used to force all data modifications to follow the criteria set within a SELECT statement given in the CREATE VIEW statement.

The WITH ENCRYPTION clause is used with a view or stored procedure definition. Using the WITH ENCRYPTION clause changes the view or stored procedure definition to an encrypted form. This prevents anyone from viewing the statement used to create the view or stored procedure.

The WITH SCHEMABINDING clause safeguards a view definition against any structural modification of the underlying table. If a view is created with the WITH SCHEMABINDING clause, the underlying tables cannot be deleted or altered in a way that affects the view definition.

The view specified with VIEW_METADATA can return the DBLIB, ODBC, and the OLEDB APIs. When metadata information about a view is to be viewed, it is created with the VIEW_METADATA option.

Modification can be made in an existing view by using the ALTER VIEW statement.

ALTER VIEW view_name AS
SELECT columns
FROM table_name

In order to delete a view, the DROP VIEW statement is used. The syntax for the DROP VIEW statement is as follows:

DROP VIEW view_name

Index: An index is a data structure that improves the performance of queries issued against a table. An index can be created for one or more columns of a table. Once created, an index is automatically updated and used by the database. It is logically and physically independent of data. The table or other indexes remain unaffected when an index is created or deleted.

The syntax for creating an index is as follows:

CREATE [CLUSTERED] [NONCLUSTERED][UNIQUE] INDEX index_name object_name(column_name)

In order to create an AML index, the following syntax is used:

CREATE [PRIMARY] CML INDEX index_name ON object_name(xml_column_name)

Modifications can be made to an existing index by using the ALTER INDEX statement.

In order to specify rebuild option for an index or to enable an index, the following syntax is used:

ALTER INDEX index_name ON object_name
    REBUILD WITH rebuild options


In order to disable an index, the following syntax is used:

ALTER INDEX index_name


In order to drop an index, the DROP INDEX statement is used.

DROP INDEX index_name

Constraints: Constraints are implemented on a table or a view to ensure that only valid data is inserted. Constraints prevent users from inserting invalid data or updating a column of a table or view with wrong data. These constraints are as follows:

  • PRIMARY KEY constraint
  • FOREIGN KEY constraint
  • UNIQUE constraint
  • CHECK constraint
  • DEFAULT constraint
  • NULL Values

PRIMARY KEY constraint: A PRIMARY KEY constraint is implemented on a column or on a group of columns of a table. These columns identify a row of a table uniquely. A table can contain only one primary key. the column on which a primary key constraint has implemented cannot contain NULL values.

FOREIGN KEY constraint: A FOREIGN KEY constraint is implemented on a column of a table to establish referential integrity between two table. A combination of a PRIMARI KEY and a FOREIGN KEY is used in the JOIN clause to retrieve data from two or more tables.

UNIQUE constraint: UNIQUE constraint ensures that no two rows in specified column or set of columns have duplicate values. Multiple UNIQUE constraints can be defined for a table. The UNIQUE constraint can be created by using the CREATE TABLE statement while creating a table. It can also be created by using the ALTER TABLE statement while modifying the table. The UNIQUE constraint allows NULL values unless NOT NULL constraint is specified for the same column.

CHECK constraint: A CHECK constraint enforces domain integrity by limiting the values that are accepted by a column. Multiple CHECK constraints can be applied to a column. A CHECK constraint can be created by using a logical expression to validate the value to be accepted by a column. It is also possible to use multiple-columns in a CHECK constraint. For example, a CHECK constraint can be used to confirm that value in the OrderDate column bust be less then the value in the InvoiceDate column. However, a CHECK constraint cannot be created to enforce a rule that requires column value from another row in the table or column value from another table.

DEFAULT constraint: The DEFAULT constraint is a constraint in which a default value is given to the column if the value for that column in unknown. If no value is provided for that column, the default value is automatically inserted. If a default value is not provided, then NULL is inserted. If a column does not allow NULL value and default value is also not assigned for that column, an error is sent by the database engine.

In order to implement a constraint on a column while creating a table, the following syntax is used:

CREATE TABLE table_name
    CONSTRAINT constraint_name(column_name)


In order to implement a constraint on a column of an existing table, the following syntax is used:

ALTER TABLE table_name
    CONSTRAINT constraint_name(column_name)

Saturday, October 11, 2008

Aspect Oriented Programming

Aspect Oriented Programming

 Hi friends,

As c# guys we knows that OOP is the Fundamental of Maximum Code Reuse and Code separation.

Is there any technology Which provide additional Code reuse and Code separation then OOP?? yes.There is.

That is AOP(Aspect oriented Programming) In fact I also used this type of Coding in my one of my project but. I didn't know that it was Aspect Oriented Programming. Let's start with a small definition on AOP first :- "Aspect Oriented Programming is a methodology to separate cross cut code across different modules in a software system."

AOP is not Actually Concept implemented in net Framework. but we can archived using class libraries provided by .Net Framework. like System.Runtime.Remoting and Many other... If you want to know more about aspect oriented Programming you can refer Given Links.

Application Server (Dublin)

Application Server (Dublin)

- Application Server “Dublin” will first become available after the release of the .NET Framework 4.0 and Visual Studio “10”.

- Application Server “Dublin” will initially be made available for download and use by Windows Server customers; later, “Dublin” will be included in future releases of Windows Server.

- Application Server “Dublin” will extend Internet Information Services (IIS) to provide a standard host for applications that use workflow or communications.

for more feature of .net 4.0 please refer What is new in .NET 4.0?

Checked/Unchecked Arithmetic:

Checked/Unchecked Arithmetic:

When a value exceeds the limitations of a data type, it is said to overflow, this can sometime produce unexpected result.It can even be dangerous, particularly when using unsafe code. to prevent this type of Error C# provide two new operator. if such overflow condition in code ,it will not let that be happen and throw Exception,

(1)Checked Arithmetic: if over flow occurs in between below code Exception Occurs.


{ int i = int.MaxValue; Console.WriteLine(i); i++; Console.WriteLine(i);


(2)Unchecked Arithmetic: any overflow in unchecked operator will simply truncated.



int i = int.MaxValue; Console.WriteLine(i); i++; Console.WriteLine(i);


Fore more detail please visit.

Wednesday, October 1, 2008

Fix: Requested Registry Access is not Allowed in Visual Studio 2008

Yesterday I have installed Silverlight 2 RC0 and Silverlight 2 RC0 tools for Visual Studio 2008 SP1. The installation of the Silverlight 2 tools was successful. After it I have started my visual studio normally and started my project. At this stage one weird thing happened. Visual Studio was unable to render the XAML in design mode. I had checked my whole my code whether there is any error in code which cause error in rendering in visual studio. But when I built it, it was successfully built and run also. Then I tried to find out the actual error. I found that Visual Studio was unable to access some registry key so it was not rendering the XAML because of the user does not have access registry rights. I don't know how these rights removed. It may be a case of removing old version and patching new update to Visual Studio.

Here's the fix for grant access to user for Visual Studio 2008:

Download "subinacl" here. This is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.

After installing subinacl.exe (it will be in the C:\Program Files\Windows Resource Kits\Tools folder.) Now create a BAT file in the same folder say Fix-Visual-Studio-Registry-Access.bat. Now paste the following commands in that bat file.

subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f /grant=system=f subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f /grant=system=f subinacl /subdirectories %SystemDrive% /grant=administrators=f /grant=system=f subinacl /subdirectories %windir%\*.* /grant=administrators=f /grant=system=f

Now you will have questions that what these commands will do. These commands will give administrators and system user of the pc access to HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, HKEY_CLASSES_ROOT, access to the system drive and access to the windows directory.

Now run your Visual Studio with Administrator Privilege and you will see All Fixed. Now Visual Studio will have permission to the registry and windows directory so it will not raise error "Requested Registry Access is not Allowed."

Tuesday, September 16, 2008

Encrypt/Decrypt Data with SQL Server 2005 : Security with SQL Server 2005

Now a days security is very much concern for websites. We can use many security options. Like use an SSL, encrypt/decrypt with C# code and another option is to use the encryption/decryption in SQL Server 2005.

There is Great Functionality in SQL Server 2005 Which Comes Handy to make your web site Secure.I will Give You Some Magic Code to Encrypt and decrypt data in SQL server.To Encrypt/Decrypt in SQL Server you need One Key(Secured Key), which we can use. Here is the syntax for creating a key to Encrypt/Decrypt data in SQL Server.

Create Symmetric Key SecuredKey



Here “Haresh” is Password and “Secured Key “is Key Name To process data key generated above should be open first to Encrypt/Decrypt in SQL Server.

Open Symmetric Key SecuredKey

DECRYPTION by Password=N'Haresh';

After Opening key you can perform Encryption or decryption in SQL Server

Below In The Complete Code For Above Operations.

Declare @Encrypted varbinary(max)

Declare @Decryptrd varchar(100)

Open Symmetric Key SecuredKey

DECRYPTION by Password=N'Haresh';

set @Encrypted= EncryptByKey (Key_GUID('SecuredKey'),'Haresh Dhameliyua')

set @Decryptrd =DecryptByKey (@Encrypted)

Print @Encrypted

Print @Decryptrd


Please let me know if you have further questions regarding Encrypt/Decrypt in SQL Server.

Friday, September 12, 2008

Remove Invalid Characters Using C#,SQL or Javascript

To provide search your application some time you need to replace invalid Characters from value submitted by user to prevent SQL injection or some other this time you can do this in three defferent ways.

You can use one of the tree way for remove Special Characters from String as per you search requirement


Use Regular Expression For Replacing Invalid Charactervar invalidChars=document.getElementById("txtAllchars").value; document.getElementById("txtAllchars").value=invalidChars.replace(/[^a-zA-Z 0-9]+/,'');


Yu can Use System.Text.RegularExpression Name spaceUsing RegEx Class You can aloow Only Valida Characters other Invalid Character will be removed

objProperty.ZipCode = Regex.Replace(txtZipCode.Text, "[^A-Za-z0-9]+", "");


In SQL There Is Not Direct method To Do this So You Need To Apply Following Code To perform task.

declare @strMain varchar(200) declare @charsToReplace varchar(10) set @charsToReplace ='^&%' set @strMain='Haresh%%^^&&' declare @i int set @i=len(@charsToReplace) while(@i>0) Begin declare @tmp char set @tmp= substring(@charsToReplace,@i,len(@charsToReplace)) set @strMain= replace(@strMain,@tmp,'') set @i=@i-1 End print @strMain

How to set Favicon in Mozilla and IE

How to set Favicon in Mozilla and IE Hi. As we Know in all web there is always Icon before site URL in addressbar. We need Favicon.ICO File and Put Following Code in Head Tag of Page link rel="shortcut icon" href="~/App_Themes/SkinFile/Images/favicon.gif" This Code Will Not Works For Some Versions of Internet Explorer. I Found Solution For That Just Pu Folowing Code You will Get Favicon in Both Mozill and IE link rel="shortcut icon" href="../App_Themes/SkinFile/Images/favicon.ico" type="image/" Thanks.

Wednesday, September 3, 2008

Change ASP.NET Validator ErrorMessage Using Javascript

This Post helps You in Changing Validatiors Errormessage Dynamically One Upon in I was Developing Video Upload Module Using Teleric File Upload. I want that FileUpload input should not blank .as well Should Accept Only .FLV Files.As i can be able to useRequireFieldValidatior .So I Use CustomValidator . In CustomeValidator Using ClientValidationFunction="validateRadVideoUpload" Property U can write fileInputs[0].value.length <= 1 to validate for '"Required Filed". So what For it should Contain .FLV at the end?? It Is easy to check Using Regular Expression. Now Problem Is Here. How will you change ErrorMessage Of CustomValidator To "Required Valid File" If user Enter file with invalid Extension. I have To Use Javascript Right?? Here is The Solutions. var Validate_VideoclientId='<%= Validate_Video.ClientID %>'; var tmp_Validate_VideoclientId = document.all ? document.all[Validate_VideoclientId] : document.getElementById(Validate_VideoclientId); tmp_Validate_VideoclientId.errormessage = "Please select valid VideoFile"; This the way u can change ErrorMessage Property of ValidationControl Dynamically. Nees Morehelp?? Write me on This Blog..Thanks

Find Currently running query/process in MS SQL Server 2005

Hi Friends,

While managing a server, we might come across a point where we want to know which of our database is loading on the server.

Let's take a case. We have hosted many sites on a server with MS SQL Server 2005. Now the traffic on some sites suddenly increase or new code is uploaded to some of site. This causes the MS SQL Server 2005 and as well server to be on a hike of 100% CPU usage.

Now we want to investigate that which query or process of MS SQL Server 2005 causing to take the CPU on the 100%  of usage. I found many people that are searching for finding currently running query/process in MS SQL Server 2005. Here is a help for them to find out which queries are currently running in MS SQL Server 2005.


You can run this query.


Other queries I found are


SELECT   st.text, r.session_id, r.status, r.command, r.cpu_time, r.total_elapsed_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS st


Now if you have the session id of your request then you can try with this query

sys.dm_exec_requests r
sys.dm_exec_sql_text(sql_handle) AS st

WHERE r.session_id = <spid number>

Here <spid number> is your session id.

Friday, August 29, 2008

Button OR Page Event Handlers Fires Twice:

  1. You have Provide Event Handler In Both Code Behind and Front(.aspx) file a. bntGet.Click += new EventHandler(bntGet_Click); b. asp:Button ID="bntGet" runat="server" Text="GetDate" OnClick="bntGet_Click" Solution:Remove Event Handler From One of the Places
  2. You have Not Given ImageUrl Property If Asp Image Control. This Problem Occurs Only in Mozill.

Tuesday, July 8, 2008

MS SQL Server 2005 Implementation & Maintenance Certification with uCertify PrepKit

Microsoft SQL Server 2005 is one of the most using database engine now a days. Microsoft has provided a great interface and userfriendliness with the SQL Server Management Studio. Most of the .net developers are working with SQL Server, they just writing the query along with their need. They even doesn't think for the performance issues with SQL Server. To get the best performance from the SQL Server first we need to know how to implement it and how to maintain it. Until we know the basics for SQL Server implementation we will suffer for performance even if we have latest hardware with higher performance. Now the developer will say "Why does we need to learn the SQL Server?" the answers is - now a days competition in market is increasing, each company need the skill full and knowledge person, who can make their company grow higher. Every large company have DBA for analyzing and performance tuning for the database. But small companies will need developer who can work on SQL server. At this time SQL Server implementation is required. In the other case if the company got server hardware crash or database hack, we need the knowledge for maintenance of the SQL Server. The person who like to go on the DBA side for SQL Server Microsoft is providing a base Certification which can put the person in priority. Microsoft provide certification of MCTS 70-431 SQL Server Implementation & Maintenance. In this certification course Microsoft will check the person's knowledge of:-
  • Installing and Configuring SQL Server
  • Implementing High Availability and Disaster Recovery
  • Supporting Data Consumers
  • Maintaining Database
  • Monitoring performance of the server., etc.

Most of the developers will be unaware of the above concepts. But still it is beneficial for the developer and the client. Because more the application work smooth more client will be happy. Now developer will ask "How will we be able to get certified when we does not have enough knowledge of the basics?" Here is the solution uCertify provides PrepKits for different Certification.

Prep kits are basically test simulator of the certification exams. It contains notes, articles and many more features. Here is the detailed list of the features included in latest MCTS 70-431 PrepKit.

  • Exam Objectives - to let the user know what should they know
  • Quiz - to create a customize timed test.
  • Study Notes - Notes that are rarely noticed by the developer which helps to go deeply in the fundamentals of the SQL Server
  • Articles
  • How Tos... - This is the coolest part of the PrepKit because it gives you visual and theory to complete a task.

PrepKit Reports

PrepKit gives you the report of your progress. PrepKit gives you the retest based on what you need you can select the category for retest. Category included are "Answered wrong", "Answered right", "All Questions", etc.

User friendliness of the PrepKit

When i first downloaded the PrepKit I was curious and confused that how will I go through the PrepKit. Will I be able to use it properly? But when I started the PrepKit I wondered with the functionality included on the first page of the PrepKit. It contains all I need in single one page. The study notes, articles, tests, test reports, all the things to start preparation for the certification.

Tests included for the preparation

uCertify has give number of tests to check your knowledge. You can start predefined tests, custom test, fixed time test, Adaptive test. The test I like the most is Adaptive, it is ask you question as you are on the go. First question will be normal difficulty, if you answer correctly then it will ask you next question will be with higher difficulty.

Test History

uCertify also give you the test history in PrepKit. It will keep a track on the test you given. So you can observe your progress.

In some case PrepKit also work as your tutor. It will give you information at which point you are wrong and at which point you need improvement.

Multiple PrepKit Support

All uCertify PrepKit can be opened from each other. You just need to go to the change menu of the certification. It will load list of installed and available PrepKits you can choose either of them. And at the same time PrepKit will be changed. So no need to wait for opening the other instance of the application.

Readiness Report

uCertify PrepKit gives readiness report to you on categories like

  • Diagnostic test
  • Test a
  • Test b
  • Test c
  • Final test
  • All

In this readiness report you can observer your knowledge for different tests and improve your knowledge on perticular point.

If you are preparing for MCTS 70-431 you must look at uCertify PrepKit. I am sure that you will like it and be one of the fan of it.

You will get 10% discount on MCTS 70-431 Certification PrepKit when you use the discount code as "NBHATT".

Thursday, June 12, 2008

Visual Studio 2008 and .NET 2.0

HI.Friends Recently I m Working With Visual Studio 2008 and .Net 3.5 But I found that VS2008 can also Be used With .Net 2.0 and it Is more Powerful in some areas where VS2005 has poor functionality.So

So why use VS 2008 if you aren't using the new .NET 3.5 features?

  1. JavaScript intellisense
  2. Much richer JavaScript debugging
  3. Nested ASP.NET master page support at design-time
  4. Rich CSS editing and layout support within the WYSIWYG designer
  5. Split-view designer support for having both source and design views open on a page at the same time
  6. A much faster ASP.NET page designer - with dramatic perf improvements in view-switches between source/design mode
  7. Automated .SQL script generation and hosting deployment support for databases on remote servers

Wednesday, June 11, 2008

Overview to Reverse Ajax

An introduction to Reverse Ajax Despite all the hype, Ajax cannot get real time information directly from the server. If some information arrives after the user has loaded a page they will never see it, unless they refresh the page. We could easily solve this problem in the traditional way, by having a having a little bit of Javascript in the webpage that automatically refreshes the page every few seconds. But refreshing an entire page every few seconds is overkill. If the millions of users of a large site were to refresh every few seconds it would increase the bandwidth dramatically. The effect on the servers would be similar to a DOS attack! We really just need the small piece of real time data to be updated on the browser as soon as it arrives in the server. The simplest way would be to have the server tell all the browsers that the data has been updated. But as we discussed in the introduction to Ajax, servers cannot initiate contact with browsers. Hence we need a solution which gets around this problem. Reverse Ajax allows servers to push content out to browsers immediately it becomes available

SQL Server Case Sensitive or case insensitive Quries

When we need That Comparison in SQL server should be Case Sensitive or Case Insensitive Regardless Database is configured or Not for Case Sensitivity We can Write Such Queries Using Following Syntax.

By default queries behave as per Database configured.

(1)Default Query:

SELECT * FROM Members WHERE Email = ‘

(2)Case Sensitive Query:

SELECT * FROM Members WHERE Email = ‘ COLLATE SQL_Latin1_General_CP1_CS_AS

Above query will matches And Not Matches DHAMELIYAHARESH@GMAIL.COM

(3)Case Insensitive Query:

SELECT * FROM Members WHERE Email = ‘ COLLATE SQL_Latin1_General_CP1_CI_AS

Above query will matches as well as DHAMELIYAHARESH@GMAIL.COM

Friday, May 23, 2008

Query XML in SQL-2005

Hi friends lets take one look at new feature of SQL-2005 which Supports Query sql Data like relational database. it is rarly used but powerful feature of database.generally this it is not feasible to use XML as relational database but when you have information in which columns are varies frequently in such situation you can Use such feature. and u might know that SQL-2005 have new datatype called xml datatype. Using power of XQuery and XML datatype we fatch data in Tabular format. Declare @XMLFriends xml set @XMLFriends ='hareshParesh'

Select'.','VARCHAR(200)') as FriendId FROM @XMLFriends.nodes('/User/name') as ParamValues(name) Output of above query is: 1 haresh 2 nirav

Wednesday, May 21, 2008

URL Validation With Javascript

Hi friends. in this post i will explain How can we Validate Web abbress. Once upon i want regular expression in my application which can eliminate full url like ( Not just i tried hard to find but i cant. so i have to develop my own. This is the function i have used:
function ValidateURL(url) { var regexp=new RegExp('^(http[s]?://ftp://)(w{3}\.{1})([A-Za-z0-9]+\.{1}) (comedugovintmilnetorgbizarpainfonameproaerocoopmuseum([a-zA-Z]{2})) ((\.{1})([A-Za-z0-9]{2,3}))?$'); if(!url.match(regexp)) { alert('Please Enter a valid URL: For Eg. "" or "" '); return false; } } You can refer Below Post for develop your own Regular expression on article Regular Expression Syntax & use in ASP.Net C#.Net

Saturday, May 17, 2008

Regular Expression Syntax & use in ASP.Net C#.Net

First of all we will know what is Regular Expression. A regular expression (or RE) specifies a set of strings that matches it; the functions in this module let you check if a particular string matches a given regular expression (or if a given regular expression matches a particular string, which comes down to the same thing).
Regular expressions can be concatenated to form new regular expressions; if A and B are both regular expressions, then AB is also a regular expression. In general, if a string p matches A and another string q matches B, the string pq will match AB. This holds unless A or B contain low precedence operations; boundary conditions between A and B; or have numbered group references. Thus, complex expressions can easily be constructed from simpler primitive expressions like the ones described here.
Regular expressions can contain both special and ordinary characters. Most ordinary characters, like "A", "a", or "0", are the simplest regular expressions; they simply match themselves. You can concatenate ordinary characters, so last matches the string 'last'. (In the rest of this section, we'll write RE's in this special style, usually without quotes, and strings to be matched 'in single quotes'.)
Some characters, like "" or "(", are special. Special characters either stand for classes of ordinary characters, or affect how the regular expressions around them are interpreted.
The special characters that used in Regular Expression are:
(Dot.) In the default mode, this matches any character except a newline. If the DOTALL flag has been specified, this matches any character including a newline.
(Caret.) Matches the start of the string, and in MULTILINE mode also matches immediately after each newline.
Matches the end of the string or just before the newline at the end of the string, and in MULTILINE mode also matches before a newline. foo matches both 'foo' and 'foobar', while the regular expression foo$ matches only 'foo'. More interestingly, searching for foo.$ in 'foo1\nfoo2\n' matches 'foo2' normally, but 'foo1' in MULTILINE mode.
Causes the resulting RE to match 0 or more repetitions of the preceding RE, as many repetitions as are possible. ab* will match 'a', 'ab', or 'a' followed by any number of 'b's.
Causes the resulting RE to match 1 or more repetitions of the preceding RE. ab+ will match 'a' followed by any non-zero number of 'b's; it will not match just 'a'.
Causes the resulting RE to match 0 or 1 repetitions of the preceding RE. ab? will match either 'a' or 'ab'.
*?, +?, ??
The "*", "+", and "?" qualifiers are all greedy; they match as much text as possible. Sometimes this behaviour isn't desired; if the RE <.*> is matched against '<H1>title</H1>', it will match the entire string, and not just '<H1>'. Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few characters as possible will be matched. Using .*? in the previous expression will match only '<H1>'.
Specifies that exactly m copies of the previous RE should be matched; fewer matches cause the entire RE not to match. For example, a{6} will match exactly six "a" characters, but not five.
Causes the resulting RE to match from m to n repetitions of the preceding RE, attempting to match as many repetitions as possible. For example, a{3,5} will match from 3 to 5 "a" characters. Omitting m specifies a lower bound of zero, and omitting n specifies an infinite upper bound. As an example, a{4,}b will match aaaab or a thousand "a" characters followed by a b, but not aaab. The comma may not be omitted or the modifier would be confused with the previously described form.
Causes the resulting RE to match from m to n repetitions of the preceding RE, attempting to match as few repetitions as possible. This is the non-greedy version of the previous qualifier. For example, on the 6-character string 'aaaaaa', a{3,5} will match 5 "a" characters, while a{3,5}? will only match 3 characters.
Either escapes special characters (permitting you to match characters like "*", "?", and so forth), or signals a special sequence; special sequences are discussed below. If you're not using a raw string to express the pattern, remember that Python also uses the backslash as an escape sequence in string literals; if the escape sequence isn't recognized by Python's parser, the backslash and subsequent character are included in the resulting string. However, if Python would recognize the resulting sequence, the backslash should be repeated twice. This is complicated and hard to understand, so it's highly recommended that you use raw strings for all but the simplest expressions.
Used to indicate a set of characters. Characters can be listed individually, or a range of characters can be indicated by giving two characters and separating them by a "-". Special characters are not active inside sets. For example, [akm$] will match any of the characters "a", "k", "m", or "$"; [a-z] will match any lowercase letter, and [a-zA-Z0-9] matches any letter or digit. Character classes such as \w or \S (defined below) are also acceptable inside a range. If you want to include a "]" or a "-" inside a set, precede it with a backslash, or place it as the first character. The pattern []] will match ']', for example. You can match the characters not within a range by complementing the set. This is indicated by including a "^" as the first character of the set; "^" elsewhere will simply match the "^" character. For example, [^5] will match any character except "5", and [^^] will match any character except "^".
AB, where A and B can be arbitrary REs, creates a regular expression that will match either A or B. An arbitrary number of REs can be separated by the "" in this way. This can be used inside groups (see below) as well. As the target string is scanned, REs separated by "" are tried from left to right. When one pattern completely matches, that branch is accepted. This means that once A matches, B will not be tested further, even if it would produce a longer overall match. In other words, the "" operator is never greedy. To match a literal "", use \, or enclose it inside a character class, as in [].
Matches whatever regular expression is inside the parentheses, and indicates the start and end of a group; the contents of a group can be retrieved after a match has been performed, and can be matched later in the string with the \number special sequence, described below. To match the literals "(" or ")", use \( or \), or enclose them inside a character class: [(] [)].
This is an extension notation (a "?" following a "(" is not meaningful otherwise). The first character after the "?" determines what the meaning and further syntax of the construct is. Extensions usually do not create a new group; (?P<name>...) is the only exception to this rule. Following are the currently supported extensions.
(One or more letters from the set "i", "L", "m", "s", "u", "x".) The group matches the empty string; the letters set the corresponding flags (re.I, re.L, re.M, re.S, re.U, re.X) for the entire regular expression. This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the compile() function. Note that the (?x) flag changes how the expression is parsed. It should be used first in the expression string, or after one or more whitespace characters. If there are non-whitespace characters before the flag, the results are undefined.
A non-grouping version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.
Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name. Group names must be valid Python identifiers, and each group name must be defined only once within a regular expression. A symbolic group is also a numbered group, just as if the group were not named. So the group named 'id' in the example above can also be referenced as the numbered group 1. For example, if the pattern is (?P<id>[a-zA-Z_]\w*), the group can be referenced by its name in arguments to methods of match objects, such as'id') or m.end('id'), and also by name in pattern text (for example, (?P=id)) and replacement text (such as \g<id>).
Matches whatever text was matched by the earlier group named name.
A comment; the contents of the parentheses are simply ignored.
Matches if ... matches next, but doesn't consume any of the string. This is called a lookahead assertion. For example, Isaac (?=Asimov) will match 'Isaac ' only if it's followed by 'Asimov'.
Matches if ... doesn't match next. This is a negative lookahead assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if it's not followed by 'Asimov'.
Matches if the current position in the string is preceded by a match for ... that ends at the current position. This is called a positive lookbehind assertion. (?<=abc)def will find a match in "abcdef", since the lookbehind will back up 3 characters and check if the contained pattern matches. The contained pattern must only match strings of some fixed length, meaning that abc or ab are allowed, but a* and a{3,4} are not. Note that patterns which start with positive lookbehind assertions will never match at the beginning of the string being searched; you will most likely want to use the search() function rather than the match() function:
>>> import re
>>> m ='(?<=abc)def', 'abcdef')
This example looks for a word following a hyphen:
>>> m ='(?<=-)\w+', 'spam-egg')
Matches if the current position in the string is not preceded by a match for .... This is called a negative lookbehind assertion. Similar to positive lookbehind assertions, the contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind assertions may match at the beginning of the string being searched.
Will try to match with yes-pattern if the group with given id or name exists, and with no-pattern if it doesn't. no-pattern is optional and can be omitted. For example, (<)?(\w+@\w+(?:\.\w+)+)(?(1)>) is a poor email matching pattern, which will match with '<>' as well as '', but not with '<'. New in version 2.4.
The special sequences consist of "\" and a character from the list below. If the ordinary character is not on the list, then the resulting RE will match the second character. For example, \$ matches the character "$".
Matches the contents of the group of the same number. Groups are numbered starting from 1. For example, (.+) \1 matches 'the the' or '55 55', but not 'the end' (note the space after the group). This special sequence can only be used to match one of the first 99 groups. If the first digit of number is 0, or number is 3 octal digits long, it will not be interpreted as a group match, but as the character with octal value number. Inside the "[" and "]" of a character class, all numeric escapes are treated as characters.
Matches only at the start of the string.
Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character. Note that \b is defined as the boundary between \w and \ W, so the precise set of characters deemed to be alphanumeric depends on the values of the UNICODE and LOCALE flags. Inside a character range, \b represents the backspace character, for compatibility with Python's string literals.
Matches the empty string, but only when it is not at the beginning or end of a word. This is just the opposite of \ b, so is also subject to the settings of LOCALE and UNICODE. \d
When the UNICODE flag is not specified, matches any decimal digit; this is equivalent to the set [0-9]. With UNICODE, it will match whatever is classified as a digit in the Unicode character properties database.
When the UNICODE flag is not specified, matches any non-digit character; this is equivalent to the set [^0-9]. With UNICODE, it will match anything other than character marked as digits in the Unicode character properties database.
When the LOCALE and UNICODE flags are not specified, matches any whitespace character; this is equivalent to the set [ \t\n\r\f\v]. With LOCALE, it will match this set plus whatever characters are defined as space for the current locale. If UNICODE is set, this will match the characters [ \t\n\r\f\v] plus whatever is classified as space in the Unicode character properties database.
When the LOCALE and UNICODE flags are not specified, matches any non-whitespace character; this is equivalent to the set [^ \t\n\r\f\v] With LOCALE, it will match any character not in this set, and not defined as space in the current locale. If UNICODE is set, this will match anything other than [ \t\n\r\f\v] and characters marked as space in the Unicode character properties database.
When the LOCALE and UNICODE flags are not specified, matches any alphanumeric character and the underscore; this is equivalent to the set [a-zA-Z0-9_]. With LOCALE, it will match the set [0-9_] plus whatever characters are defined as alphanumeric for the current locale. If UNICODE is set, this will match the characters [0-9_] plus whatever is classified as alphanumeric in the Unicode character properties database.
When the LOCALE and UNICODE flags are not specified, matches any non-alphanumeric character; this is equivalent to the set [^a-zA-Z0-9_]. With LOCALE, it will match any character not in the set [0-9_], and not defined as alphanumeric for the current locale. If UNICODE is set, this will match anything other than [0-9_] and characters marked as alphanumeric in the Unicode character properties database.
Matches only at the end of the string
Now we will see how can we use Regular Expression with ASP.Net and C#.Net
Some time we need to check for a field that whether it contains only characters or not. Suppose we have field for First Name then it should contain only characters not and digits and not any special characters. For this we can use Regular Expression. In ASP.Net we have RegularExpressionValidator server control. This control have property ValidationExpression in which you have to set your Regular Expression. For only characters we will create a range of characters [a-z] this will allow only small letters and only one character, so we will use [a-zA-Z]* it will allow capital and small letters and any number of characters in the text.

Syntax for RegularExpressionValidator is :

<asp:RegularExpressionValidator ID="rev_FirstName" runat="server" ControlToValidate="txt_FirstName" ErrorMessage="Only characters allowed" ValidationExpression="[a-zA-Z]*" ></asp:RegularExpressionValidator>

Now use Regular Expression in C#.Net, we will use namespace System.Text.RegularExpressions
When we add this name space we will get Regex class reference. We will create an object of this class.
Regex syntax is :
Regex re = new Regex("Regular Expression string",Regular Expression Options);
Regular Expression Options are options that we can use along with regular expression like RegexOptions.IgnoreCase or RegexOptions.Compiled
Here I am lisitng some Regular Expressions:
[a-zA-Z]* - Regular Expression to allow only charactors
[0-9]* - Regular Expression to allow only numbers
[a-zA-Z0-9]* - Regular Expression to allow only alphanumeric charactors
[0-9]*(\.[0-9]{1,2})? - Regular Expression to validate a float number with 1 or 2 decimal points

For some more regular expression checkout my post Sample regular expression - Numeric, Decimal, Alphanumeric, Date

You can request Regular Expression here....

Thursday, April 3, 2008

Validating E-Mail Address Using JavaScript Regular Expression:

In this Post I will tell you how to Validate E-Mail address format using javascript regular expression

function ValidateEmail()
var EmaiAddress=document.getElementById("txtemail").value;
var RegExEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
if (!RegExEmail.test(EmaiAddress))
alert("Please Enter Valid E-mail Adress");
alert("Go Ahead!");

All i have done in above code is Call ValidateEmail function on click of a Button named Checkit! and check value in text element. to call function write onclick="ValidateEmail()" in attribute of button element

Thursday, January 24, 2008

Scheduling and Event Logging Windows Service

In previous post we had seen how to create a windows service. In this part we will see how can we log events in windows service and how to schedule service to occur at specific interval.

First we will see how we can Log events in EventViewer event of Windows Service. Steps are as follows.

- Add an EventLog to your windows service class, from Toolbox.

- Give an ID say "MyEventLog1", Set Log to "MyEventLog" and Source to "MyEventLogSource"

This will help you to differentiate your log in event viewer. And you can also create a new view of your event source log. Create new Log View on application and rename it to "MyEventLogSource". Now clear logs, then each new entry with log source "MyEventLogSource" will be logged in the new view.

Now how will we write a new log entry in Windows Service.

Write the following code in OnStart Code block of your Service.

MyEventLog1.WriteEntry("My Windows Service Started.......");

This will be write a log entry. But make sure that you write this code in try-catch block, because on some OS, Windows Service do not have permission to log events. At that time your service will generate an unhandeled exception and it will stop immediately and you will unable to identify the problem that why your service is stopped immediately after it starts.

There can be two types of windows service.

1) Windows service that run only once. There is no any scheduling of the service. If you want to run it again the you must start the service again. It will stop automatically after it complete its job.

2) Windows service that run at specific interval. This service is useful to run Insert command from one server to other backup server. Or it can be use to complete tasks that are added in Database.

The first type of Windows service is very easy. Just put your code in OnStart event of the Windows Service.

Scheduling Windows Service with Timer Control

For scheduling a Windows service declare two global variables in your service class (Make sure not in Service.designer.cs Designer class)
This timer control is not System.Timer, this control is

private Timer stateTimer;

private TimerCallback timerDelegate;

Timer is useful for creating the scheduling the Service. TimerCallback is useful for specifying the function which will be called when timer interval ends(Tick event fires).

Now write this code in your OnStart block.

timerDelegate = new TimerCallback(DoSomething);
stateTimer = new Timer(timerDelegate, null, 0, 5000); // 5000 = 5 secs

In above code the timerDelegate is a callback function which will specify the Function that will be called each time your timer fires tick event.

Now the stateTimer is assigned to a new timer object which specify timerDelegate, initial delay and interval. In above example '0' is initial delay which specify after timer object is created how much to delay for firing first Tick event. '5000' this specify the interval, this indicate the delay of firing the tick event since the last tick event is fired. Both Initial delay and Interval are specified in milisecond.

Now we will see how to create the function.

protected void DoSomething(object sender)
MyEventLog1.WriteEntry("Windows Service event fired at " + DateTime.Now.ToString());

Above I have specified the function to be fired at tick event of timer. It will log in EventViewer with date and time.

In next part we will see how can we add a configuration file to the Windows Service, how to install the service and common problem while using with Windows Server 2003 system.