Blog

Get the referring page on Page_Load event in ASP.NET

When a page loads, in order to get the name of the page that sent you there, all you need to use is: Request.UrlReferrer.ToString(); You can create a global variable to hold it: string sReferrer = ""; Then, in the Page_Load event, assign it: if (!Page.IsPostback) { sReferrer = Request.UrlReferrer.ToString(); } Or, you can put it in ViewState at...

Confirmation message upon deleting an item from GridView control in ASP.NET

Lots of users click the delete button within the GridView with no attention then the result is that the item will be deleted from the GridView, so we can add confirmation message to appear to tell the user "Are you sure you want to delete this item?". First of all we have to attach the javascript code...

Add static item to DropDownList web control after data bind in ASP.NET

Sometimes we need to add a static item to the top of DropDownList web control, such as "-- Please select --" or any other text. This static item will be removed and replaced with the items that comes from the data source you are using after calling DataBind() method.  To keep the static item you are...

String functions StartsWith and EndsWith are case-sensitive in .NET

Did you know that String functions StartsWith and EndsWith are case-sensitive even in VB.NET? You will need to make sure you are looking for the correct string, since 'abc' with case-sensitivity is different than 'ABC'. So, if your function is looking for 'abc', you must make sure that you make adjustments to the string, in...

Disable configuration inheritance in ASP.NET

Configuration inheritance is a very good feature of ASP.NET. It allows you to set configuration settings in the Web.config file of a parent application and have it automatically be applied to all of its child applications. But sometimes you do not want the child applications to inherit the configuration from its parent application, so you...