StatCounter

View My Stats

Wednesday, February 6, 2008

Text Box Initialization when it is Password Mode in .NET

Text Box Initialization when it is Password Mode in .NET


If u r having a textbox in a form.The textmode of the textbox is Password.

Under this type of situation if u want to initialize a password while the page load we will normally gave at the Page_Load

TextBox1.Text="Hi";

But the above wont't work when the TextBox mode is set to password. To do this write the below code at the page Load

TextBox1.Attributes.Add("value","Hi"); //This work Fine

Text Reader in .NET

Text Reader in .NET


FileInfo File = new FileInfo("D:\\READ\\ec_books_new.txt");
if (File.Exists)
{
TextReader Tr = new StreamReader("D:\\READ\\ec_books_new.txt")
string Line;
Line = Tr.ReadLine();
while (Line != null)
{
Console.WriteLine(Line);
Line=Tr.ReadLine();
}
}

Money Convertor WebService Link

Difference between Hyperlink and LinkButtton in ASp.NET

Difference between Hyperlink and LinkButtton in ASp.NET


To the Web page visitor, a HyperLink control and a LinkButton control look identical. However, there is a significant difference in functionality.

The HyperLink control immediately navigates to the target URL when the user clicks on the control. The form is not posted to the server.

The LinkButton control first posts the form to the server, then navigates to the URL. If you need to do any server-side processing before going to the target URL, use a LinkButton.

On the other hand, if there is no server-side processing necessary, don't waste a round trip and use the HyperLink control.

To create a Thumpnail Image in .NET

To create a Thumpnail Image in .NET


The coding is listed below:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public partial class ThumpNailImage : System.Web.UI.Page

{
#region Declaration
string[] ImageFormat = { "jpg", "JPG", "jpeg", "JPEG", "gif", "GIF" };
string ImagePath = System.Configuration.ConfigurationManager.AppSettings["PrdUplodPath"];
#endregion
protected void Page_Load(object sender, EventArgs e)

{
//string CODE = Request.QueryString["CODE"].ToString();
string PRD_CODE = "PRD1";
#region Retrieve Image
for (int i = 0; i <= ImageFormat.Length - 1; i++)
{
FileInfo Fileinfo = new FileInfo(Server.MapPath(ImagePath) + PRD_CODE + "_S." + ImageFormat[i]);
if (Fileinfo.Exists)
{
string file = Server.MapPath(ImagePath) + PRD_CODE + "_S." + ImageFormat[i]; System.Drawing.Image image = System.Drawing.Image.FromFile(file); System.Drawing.Image thumbnailImage = image.GetThumbnailImage(150, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); MemoryStream imageStream = new MemoryStream(); thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] imageContent = new Byte[imageStream.Length]; imageStream.Position = 0;
imageStream.Read(imageContent, 0, (int)imageStream.Length); Response.ContentType = "image/"+ImageFormat[i]+"";
Response.BinaryWrite(imageContent);
}
}
#endregion
}
public bool ThumbnailCallback()
{
return true;
}

}

How to get Previous Page URL in ASP.NET

How to get Previous Page URL in ASP.NET


Request.UrlReferrer.ToString();

u can easily get a previous page URL