Google Search

Google
 

Friday, August 31, 2007

MaxLength in TextBox control in ASP.Net

When I was use TextBOx with TextMode "MultiLine" and MaxLength "10".I can enter more than 10 characters. SO I use Java Script for that and it solve my problem.

JavaScript like this :

< script language="javascript" >
function limitCharsLength(Object, MaxLen)
{
return (Object.value.length <= MaxLen-1);
}
< /script >


and TextBox like this :

< asp:TextBox ID="TextBox1" runat="server" Height="173px" TextMode="MultiLine"
Width="369px" onkeypress="javascript: return limitCharsLength(this,5);"
onblur="javascript: limitCharsLength(this, 5)"
onchange="javascript : return limitCharsLength(this, 5)" >< /asp:TextBox >

Wednesday, August 22, 2007

ThumbNail Creation in ASP.Net

Creation of thumbnails from image in ASP.Net is very easy task.

Following are Steps to create thumbnails image in ASP.Net :

1)Read the Image using the method Image.FromStream() as,

Dim imInputImage, imThumbNail As Image

imInputImage = System.Drawing.Image.FromStream(imgUpload.PostedFile.InputStream)


here,imgUploadis the id of FileUpload Control.

2)Get the ThumbNail Image using the method GetThumbnailImage.

imThumbNail = imInputImage.GetThumbnailImage(100, 100, Nothing, System.IntPtr.Zero)

We can also specify the format of the Thumbnail image we want to save by,

imThumbNail.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)

Some of the Formats can be,
Jpeg- System.Drawing.Imaging.ImageFormat.Jpeg
Gif - System.Drawing.Imaging.ImageFormat.Gif
Tiff- System.Drawing.Imaging.ImageFormat.Tiff
Png - System.Drawing.Imaging.ImageFormat.Png

Thursday, August 2, 2007

Page Directives in ASP.NET 2.0

Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:

@ Assembly - Links an assembly to the current page or user control declaratively.

@ Control - Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).

@ Implements - Indicates that a page or user control implements a specified .NET Framework interface declaratively.

@ Import - Imports a namespace into a page or user control explicitly.

@ Master - Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.

@ MasterType - Defines the class or virtual path used to type the Master property of a page.

@ OutputCache - Controls the output caching policies of a page or user control declaratively.

@ Page - Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.

@ PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.

@ Reference - Links a page, user control, or COM control to the current page or user control declaratively.

@ Register - Associates aliases with namespaces and classes, which allow user controls and custom server

Folders in ASP.NET 2.0

There are seven new folders introduced in ASP.NET 2.0 :

\App_Browsers folder – Holds browser definitions(.brower) files which identify the browser and their capabilities.

\App_Code folder – Contains source code (.cs, .vb) files which are automatically compiled when placed in this folder. Additionally placing web service files generates a proxy class(out of .wsdl) and a typed dataset (out of .xsd).

\App_Data folder – Contains data store files like .mdf (Sql Express files), .mdb, XML files etc. This folder also stores the local db to maintain membership and role information.

\App_GlobalResources folder – Contains assembly resource files (.resx) which when placed in this folder are compiled automatically. In earlier versions, we were required to manually use the resgen.exe tool to compile resource files. These files can be accessed globally in the application.

\App_LocalResources folder – Contains assembly resource files (.resx) which can be used by a specific page or control.

\App_Themes folder – This folder contains .css and .skin files that define the appearance of web pages and controls.

\App_WebReferences folder – Replaces the previously used Web References folder. This folder contains the .disco, .wsdl, .xsd files that get generated when accessing remote web services.