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)
{
string[] pathCollection = new string[2];
PathCellction[0] = “c:\\folder1”;
[…]

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 some of the best ASP.NET books at http://www.howtoasp.net/asp-net-books/.

Related […]

Next ASP.NET Release Runs on OS X and Linux – 05/28/2014

Microsoft delivered a preview of the next version of its ASP.NET Web development framework at its TechEd 2014 conference, and now that software is able to run on OS X and Linux.

Microsoft announced ASP.NET vNext at TechEd on May 12. ASP.NET vNext is a streamlined framework and runtime that enables developers to optimize cloud and server […]

How to replace \n line breaks with HTML <br /> line breaks in GridView

This is very common scenario when you would like to show well formatted GridView content. To do this you could use the ItemTemplate which is used by default to render the cell for each row:

<%# ((string)Eval(“GridviewContent”)).Replace(“\n”, “<br />”) %>

Related TutorialsHow to use XML attributes
How to use Validation groups in ASP.NET 4.0
How to use XML Namespaces with […]

How to Install ASP.NET MVC using ASP.NET hosting

ASP.NET MVC

ASP.NET MVC provides a Model-View-Controller (MVC) framework for developing Web applications using Visual Studio. ASP.NET MVC also includes ASP.NET Web API, ASP.NET Web Pages, Web Optimization and NuGet, a free, open source developer focused package management system.

How to install ASP.NET MVC

ASP.NET MVC can be installed from the ASP.NET MVC home page (http://www.asp.net/mvc) using the […]

How to make the TextBox readonly or disabled in ASP.NET

You can make the TextBox control readonly by setting its ReadOnly property to true. You can set this property in the .aspx page which contains the TextBox control, or programmatically from the code-behind. The next test .aspx page shows this:

ReadOnlyTextBox.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”ReadOnlyTextBox.aspx.cs”

Inherits=”TextBoxSamplesVC.ReadOnlyTextBox” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

How to render a password type textbox in ASP.NET

You can render the TextBox control to as password type by setting its TextMode property to Password. The next test .aspx page shows this:

TextBoxAsPassword.aspx

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TextBoxAsPassword.aspx.vb”

Inherits=”TextBoxSamplesVB.TextBoxAsPassword” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Password type TextBox</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:TextBox ID=”tbPassword” runat=”server” TextMode=”Password”></asp:TextBox>

How to programmatically set the TextBox value and get the TextBox value in ASP.NET in VB.NET

The next example uses a test.aspx page named SetAndGetTextBox.aspx which has two asp:Label controls and one asp:TextBox control. In the code behind the local string variable value is use to read in it the system date and time by using:

Value = DateTime.Now.ToString

The rows in bold show how value is used to set the TextBox […]

How to programmatically set the TextBox value and get the TextBox value in ASP.NET in C#

The next example uses a test.aspx page named SetAndGetTextBox.aspx which has two asp:Label controls and one asp:TextBox control. In the code behind the local string variable value is use to read in it the system date and time by using:

value = DateTime.Now.ToString();

The rows in bold show how value is used to set the TextBox […]

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 encode HTML content and accept any of the following three values:

–  PassThrough—Displays the […]

Recommended ASP.NET Examples