Archive for February, 2008

Text Box Initialization when it is Password Mode in .NET

February 6, 2008

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 [...]

Text Reader in .NET

February 6, 2008

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

February 6, 2008

http://www.webservicex.net/CurrencyConvertor.asmx?

http://www.strikeiron.com/productdetail.aspx?p=334

Difference between Hyperlink and LinkButtton in ASp.NET

February 6, 2008

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 [...]

To create a Thumpnail Image in .NET

February 6, 2008

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 [...]

How to get Previous Page URL in ASP.NET

February 6, 2008

Request.UrlReferrer.ToString();
u can easily get a previous page URL

Reduce the Bandwidth Suffer in .NET

February 6, 2008

While using a complex control like GridView, Repeater ,DetailsView control We have to Disable the ViewState…….Otherwise it degrades the Bandwidth of your connection.
To overcome this :
Page Load
if(!Page.IsPostBack)
{
BindGrid();
}
Instead of that use:(Directly BindGrid)
Page Load
BindGrid();
The disadvantages of this Method is the Evets of the controls like RowCommand Wont Work.Check this out Properly
Use directly at the Page Load. This [...]

?? Operator in .NET

February 6, 2008

This operator is used to check whether the string is null or not.If is it null values we can set a Default value in it.
Example:
string a;//The default value of a is null

Page Load
{
a=a?? “Hi”;
Response.write(a);
}
output: Hi // we set the default value of a is null

To Add Empty Row in DataTable in ADO.NET

February 6, 2008

if ((Ds.Tables[0].Rows.Count == 0))
{
Ds.Tables[0].Rows.Add(Ds.Tables[0].NewRow());
}
Ds-DataSet Name that containes Tables

Create a DataTime With a user Specified Time

February 6, 2008

DateTime Time1=DataTime.Now;
Time1= new DateTime(SlotEndTime.Year, SlotEndTime.Month, SlotEndTime.Day, 9, 30, 0);
The Time1- Field have Today date with the time 9.30 am