Sep 18, 2012

We have moved

Hello Friends,

We have permanently moved to our new portal at Publish Article

Now and onwards we will update our new portal

Thank you.

read more

Feb 24, 2012

Enum Examples or How to Bind the DropDownList With Enum?

Enum is the type provided by dotnet, it stores constant value in it. When we want to specify some constant value to use in the project then it is very usefull for readability.

In this post I will show you how to declare an enum and how to use it in the program.
Here I have bind the enum to the dropdown list

Declare the enum as below

public enum Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }

In aspx page I have added DropDownList named ddlDays as below

 <asp:DropDownList ID="ddlDays" runat="server">

Now below is the code to bind dropdownlist control with above enum
// Add first item to the drop down list to select lable
        ddlDays.Items.Add("--Select Days--");

        string[] enumNames = Enum.GetNames(typeof(Days));
        foreach (string item in enumNames)
            int value = (int)Enum.Parse(typeof(Days), item);
            ListItem listItem = new ListItem(item, value.ToString());
            //Add one by one item to the drop down list

Out put is displayed in the side image.

read more

Feb 14, 2012

Supported languages by SyntaxHighlighter

Syntax highlighter is a tool which will highlight the code in correct Syntax. When on your blog or web site you want to show some programming code then it is very useful.

In my next post I will show you how to add Syntax Highlighter in blogger or any webpage.

Below is the list of all the supported languages with their aliases.

Language Aliases
C++ cpp, c, c++
C# c#, c-sharp, csharp
CSS css
Delphi delphi, pascal
Java java
Java Script js, jscript, javascript
PHP php
Python py, python
Ruby rb, ruby, rails, ror
Sql sql
VB vb,
XML/HTML xml, html, xhtml, xslt

For more detail visit:

read more

Feb 12, 2012

Change cursor to hand on mouseover using jQuery

When ever we need to change the mouse cursor using JQuery then we can do it very easily.

In my today's post I will show you how can we change the mouse cursor to the Hand type cursor while user hover mouse on the particular element.
It is very simple just look at the below JQuery code.

$(document).ready(function() {
  $("#elementid").hover(function() {
    $(this).css("cursor", "hand");

In above code 'elementid' is the name of the element on which you want a mouse pointer as a hand while hovering a mouse over it.

Happy Coding...

read more

Jan 7, 2012

SQL SERVER – 2005/2008 – User Defined Function to Strip HTML String Without Regular Expression

Suppose sometimes we are saving HTML string into the database(SQL Server).
Now when we want to display some limited characters on the web page like first 200 char,
return string will not be proper HTML as it will leave some open HTML tag into it and hense it will not render HTML properely on the web page and also disturb our page html.
So to avoide this problem we can strip html from the sql server. I have written an SQL UDF for that as below.

Following UDF takes input as HTML and returns TEXT only.
If there is any single quotes in HTML then it must be replaced with two single quotes while passing to the function as a input.

Create Function [dbo].[StripHTML]
(@HTMLString VarChar(Max))
Returns Varchar(Max)
    Declare @StartChar Int
    Declare @EndChar Int
    Declare @Length Int
    Set @StartChar = CharIndex('<',@HTMLString)
    Set @EndChar = CharIndex('>',@HTMLString,CharIndex('<',@HTMLString))
    Set @Length = (@EndChar - @StartChar) + 1
    While @StartChar > 0 AND @EndChar > 0 AND @Length > 0
        Set @HTMLString = Stuff(@HTMLString,@StartChar,@Length,'')
        Set @StartChar = CharIndex('<',@HTMLString)
        Set @EndChar = CharIndex('>',v,CharIndex('<',@HTMLString))
        Set @Length = (@EndChar - @StartChar) + 1
    Return LTrim(RTrim(@HTMLString))

Declare @HTMLString As VarChar(Max) = '<table class="tempwrapper"> '+
 '<tr><td colspan="3">.NET that will convert a string so that it can be eg I would like to convert the string &quot;a &lt; b&quot; '+
 'to &quot;a &#3C; b&quot;.</td> </tr> </table>'
 Select SUBSTRING(@HTMLString,0,100)
 Select SUBSTRING([dbo].[StripHTML](@HTMLString),0,100)
-> <table class="tempwrapper"> <tr><td colspan="3">.NET that will convert a string so that it can be e
-> .NET that will convert a string so that it can be eg I would like to convert the string &quot;a &lt

Here I have attached a screen shot of the UDF at action.

Happy Programming :-)

read more

Author Profile

Total Pageviews