How to get current page URL in ASP.NET

This ASP.NET Tutorial will explain how to get current page URL in ASP.NET.

To get the current page UR L you could use HttpContext.Current.Request.Url:

1. To get the full URL with query string (if any) you could use:

string absoluteurl = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:80/test/Default.aspx?test=1

2. To get the path without the domain you could use:

string absolutepath = HttpContext.Current.Request.Url.AbsolutePath;
// /test/Default.aspx

3. To get […]

How to speed up ASP.NET web site

This ASP.NET tutorial will explain how to speed up ASP.NET web site.

Many times, when you create larger ASP.NET site you need to optimize the application and IIS web server, so to improve the user experience. We say that the ASP.NET website is good optimized when server response time is bellow 200 ms (milliseconds).

Speed up ASP.NET web […]

How to zip a file or a folder in ASP.NET

This ASP.NET tutorial will explain how to zip a file or a folder in ASP.NET.

You can zip a file or a folder in ASP.NET by using java.util.zip.ZipFile, ICSharpCode.SharpZipLib.Zip or other library assemblies.

SharpZipLib can be downloaded from: http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx.

The ASP.NET examples below demonstrate how to zip files.

using ICSharpCode.SharpZipLib.Zip;
using System.IO;

ZipOutputStream zos = null;
protected void Button1_Click(object sender, EventArgs e)
{
[…]

How to learn ASP.NET

This ASP.NET tutorial will explain how to learn ASP.NET.

You can learn ASP.NET at http://www.howtoasp.net/tutorials/asp-net-tutorials/. You can learn the basics of ASP.NET first, then to watch some videos, you can also try some quick examples.

To learn more about data-access in ASP.NET you could visit http://www.howtoasp.net/tutorials/database-tutorials/. This is an important part of learning ASP.NET.

You could also read […]

How to Create a Custom Control in ASP.NET

This ASP.NET tutorial explains how to create a custom control in ASP.NET.

If none of the existing ASP.NET server controls meet your requirements, then you can create a custom control by deriving from one of the base control classes.

Adding Custom Control to the Toolbox

1. Create a test Web Forms page. (WebForm1)
2. Using Tools menu, click Add/Remove Toolbox […]

How to connect to MySQL database using ASP.NET hosting

This ASP.NET tutorial explains how to connect to MySQL database using ASP.NET hosting.

Many developers use ASP.NET with MySQL with their applicaions. If you use ASP.NET hosting services and some of ASP.NET languages as VB.NET or C# then you could connect to the MySQL databse using ODBC .net data provider.

Connect to MysQL database using C# on ASP.NET […]

How to disable a button after click in ASP.NET

This ASP.NET tutorial explains how to disable a button after click in ASP.NET.

This is a very common scenario when you would like to disable button after click, so the user could not click it again if you need some time to do some task which takes longer time to be executed.

Disable a button after click in […]

How to write encoded text on the web page in ASP.NET

This ASP.NET tutorial explains how to write encoded text on the web page in ASP.NET.

When you want to write encoded text on the web page you should use the Literal control, because it does support a property that is not supported by the Label control: the Mode property. The property enables you to […]

How to associate a Label with a TextBox or other Form control in ASP.NET

This ASP.NET tutorial explains how to associate a Label with a TextBox or other Form control in ASP.NET.

The next code shows how you can attach an asp:Label control with the asp:TextBox. In this case when the user clicks the Label the application will focus on the TextBox.

 

TestAssociate.aspx

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TestAssociate.aspx.vb” Inherits=”TextChange.TestAssociate” %>

<!DOCTYPE […]

How to use different colored highlights in a select menu with CSS

This ASP.NET tutorial explains how to use different colored highlights in a select menu with CSS.

You can assign classes to menu options, to create multiple background colors within the drop-down color. In this case you need to set only the color and background-color properties for a menu item. The next two test files show this:

 

File test.css

.blue […]

Recommended ASP.NET Examples