Assigning Session to nothing or Session.Abandon

I have seen so many developers once they wanted to destroy session, they used

Session(“A”) = Nothing

Its not a good practice to assign nothing object.





The Session.Abandon method basically destroys a user session.

One thing I would add the current Session object will not delete untill the script on the current page have been processed completely.

Sorry for your inconvience, I have my official blog please visit for complete article:







TODO Comments

Please check the detail with my official blog



ResolveUrl Method

ASP.NET’s Control class which provide a wonderful method ResolveURL thats parse relative URL’s path and make it ready and fix URL into one that is readable and usable on the requesting client.
Using tilt sign ~ that makes control execute and search inside the application.

reference path : “~/images/joggee.jpg”



<img alt=”” height=”7″ hspace=”6″ src=<%=ResolveURL(“~/images/index_40.jpg”) %> width=”4″ />



ASP.Net – Global.asax not firing

“I am experiencing problem with global.asax; events are not firing, I cant debug global.asax” One of my reader asked me.

Simple and reliable solution is.

Remove global.asax from your project and add again and leave in on the root of the project.

Since we are using ASP.Net 2.0 there is no Global.asax file in visual studio solution by default.

This will solve the problem, Global.asax


StripHTML function

If you know the meaning of Strip word you will know what does it do.  just kidding 🙂

The StripHTML function removes all HTML code from a string.
string = StripHTML(string)
Example Usage:
dim a

a = a & “<HTML>” & vbCrLf
a = a & “<HEAD>” & vbCrLf
a = a & “<TITLE>Rana’s Blog</TITLE>” & vbCrLf
a = a & “</HEAD>” & vbCrLf
a = a & “<BODY>” & vbCrLf
a = a & “-Code Project!!!” & vbCrLf
a = a & “<A href=”” mce_href=””./Rana.asp””></A>” & vbCrLf
a = a & “</BODY>” & vbCrLf
a = a & “</HTML>” & vbCrLf

response.write StripHTML(a)


Rana’s Blog – Code Project

One of my reader asked me how to do in ASP.NET 

In ASP.NET you can strip the HTML using Regex

Dim StrStripped As String

StrStripped = System.Text.RegularExpressions.Regex.Replace(“Input as String”, “Pattern like (.|\n)*?”, String.Empty)

RequiredFieldValidator , ValidationSummary

One of my readers asked me to write about validation summary of ASP.NET 2005.

A small example to help those who never used validate summary before.

I am using validationsummary control and RequiredFieldValidator to let you guys understand. 

Brief introduction:

Validation Summary:
The ValidationSummary control is used to display a summary of all validation errors  occurred in a Web page.

The error message displayed in this control is specified by the ErrorMessage  property of each validation control. If the ErrorMessage property of the validation  control is not set, no error message is displayed for that validation control.

For more detail click here.


The RequiredFieldValidator control is used to make an input control a required field.

For more detail click here

 Use below code,copy it and test at your webpage.

<table width=”100%” cellpadding=”1″ cellspacing=”6″>            <tr>                <td>                    <asp:ValidationSummary ID=”ValidationSummary1″ runat=”server” ShowSummary=”true” />                </td>            </tr>            <tr>                <td>                    <table>                        <tr>                            <td>                                <asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox></td>                            <td>                                <asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ControlToValidate=”TextBox1″                                    ErrorMessage=”Missing field One” SetFocusOnError=”True” Display=”None”> </asp:RequiredFieldValidator></td>                        </tr>                        <tr>                            <td>                                <asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox></td>                            <td>                                <asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ControlToValidate=”TextBox2″                                    Display=”none” ErrorMessage=”Missing field two” SetFocusOnError=”True”></asp:RequiredFieldValidator></td>                        </tr>                        <tr>                            <td align=”center” colspan=”2″>                                <asp:Button ID=”Button1″ runat=”server” Text=”Submit” /></td>                        </tr>                    </table>                </td>            </tr>


For any further help, write me.