Sunday, December 19, 2010

creating Temp Varaible.

http://www.eggheadcafe.com/articles/20010823.asp



Let's take a very simple example that you can test for yourself. We'll use the trusty old Northwind sample database. Let's say that you run the Northwind Traders operation and you suddenly find a new shipper whose prices on everything that you normally ship with shipper number "1" that costs over a certain price level ( let's say we've determined the level is $50.25) can now be shipped with your new shipper number 4 for a flat rate of $21. You think, "Oboy - I'll be able to put in for a raise on this one!'

So you want to update all your open orders that had instructions to use Shipper 1 where the price came out to be greater than $50.25, and change the shipper to shipper number 4 and the new flat rate of $21.00.

Now before we begin, I know and you know that we can definitely do this with a single SQL Statement using a correlated subquery with a derived table holding the items to change. But for the sake of simplicity, let's just say for the sake of example that we've decided we need to do it either with a cursor or a temporary table. Now let's see how we could do it using the new TABLE variable, and avoid all the extra disk access and locking:

USE NORTHWIND

-- we declare our table variable first

declare @SpecialCustomers TABLE (
CustomerID nchar (5) NOT NULL ,
OrderID int NOT NULL ,
ShipVia int NOT NULL,
Freight money NOT NULL)

-- now we populate the in-memory table variable with the record information needed for the update

insert into @SPecialCustomers select CustomerID, OrderID, ShipVia, Freight
from dbo.Orders where ShipVia =1 AND Freight >50.25

-- and finally we update the affected records in our regular orders table with our new shipper and price information,
-- using the @SpecialCustomers TABLE variable just as we would a real, physical table in the database:

UPDATE ORDERS SET ShipVia=4, Freight =21.00
where ORDERS.OrderID IN (SELECT ORDERID FROM @SpecialCustomers)

Tuesday, December 7, 2010

Read html and Wrtie to HTMl fiile

public static bool WriteHtmlFile(string pHtmlFileNameWithFullPath, string pValue)
{
bool mSuccess = false;

if (pValue.Trim().Length > 0)
{

try
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(pHtmlFileNameWithFullPath, false);

sw.Write(pValue);

sw.Close();
}
catch (Exception)
{
Exception ex = new Exception(pHtmlFileNameWithFullPath.Substring(pHtmlFileNameWithFullPath.LastIndexOf("\\")) + " not accessible !! contact administrator..");
throw ex;
}

mSuccess = true;
}

return mSuccess;
}

private string GetHTML1(string url, string resourceName)
{
try
{
StringBuilder content = new StringBuilder();

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

using (StringWriter writer = new StringWriter(content))
{
using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
{

writer.Write(reader.ReadToEnd());
reader.Close();
}

writer.Close();
}

return content.ToString();
}
catch (Exception ex)
{
throw ex;
}
}

public string GetAbsoluteURI(string virtualPath, string queryString, bool useSecure)
{
try
{
string path = VirtualPathUtility.ToAbsolute(virtualPath);
Uri newUri = new Uri(HttpContext.Current.Request.Url, path);

UriBuilder uriBuilder = new UriBuilder(newUri);

if (!string.IsNullOrEmpty(queryString))
{
if (queryString.StartsWith("?")) queryString = queryString.Substring(1);
uriBuilder.Query = queryString;
}

if (!useSecure)
{
uriBuilder.Scheme = "http";
if (uriBuilder.Port == 443) uriBuilder.Port = 80;
}

return uriBuilder.Uri.ToString();
}
catch
{
return string.Empty;
}
}

convert xml to HTML

private void ConvertXMLToHTML(string xmfile)
{

//string xmlPath = HttpContext.Current.Server.MapPath(xmfile);


try
{

string XSLpath = System.Configuration.ConfigurationSettings.AppSettings.Get("XSLFile").ToString();

string originalhtmlpath = System.Configuration.ConfigurationSettings.AppSettings.Get("HTMLFile").ToString();

StringBuilder strb = new StringBuilder();

//+ "/" + System.Configuration.ConfigurationSettings.AppSettings.Get("ConfigFile").ToString());

string xsltpath = VirtualPathUtility.ToAbsolute("/PdfProject/BlGeneratePdf/BlGeneratePdf/NBS.xslt");

theText1 = this.GetXSLT(xsltpath, "");
// string xslPath = HttpContext.Current.Server.MapPath("NBS.xslt");

//Instantiate the XPathDocument Class
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmfile);
////Instantiate the XslTransform Class
// XslTransform transform = new XslTransform();
// // transform.Load("NBS.xslt");
// transform.Load(XSLpath);
// XmlTextWriter writer = new XmlTextWriter(originalhtmlpath,null);
// writer.Formatting = Formatting.Indented;
// writer.Indentation=4;
// transform.Transform(doc, null, writer);

XslTransform xslt = new XslTransform();
xslt.Load(XSLpath);


XmlTextWriter writer = new XmlTextWriter(originalhtmlpath, null);

xslt.Transform(doc, null, writer);
writer.Close();
}
catch (Exception ex)
{
throw;
}




}

Tuesday, November 30, 2010

pick connection from app.config

http://www.dreamincode.net/forums/topic/45321-grabbing-connectionstring-from-appconfig/

Wednesday, November 24, 2010

PDF generation using abcpdf

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ABCpdf = WebSupergoo.ABCpdf7;
using WebSupergoo.ABCpdf7;
using System.Net;
using System.IO;
using System.Text;
using System.Configuration;
using System.Collections;

public partial class Headerfooter : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{


ABCpdf.Doc theDoc = new Doc();

//BELOW CODE IS USED TO SET COLOR OF DOCUMENT
//theDoc.Color.String = "255 0 0";

ABCpdf.Doc theDoc1 = new Doc();
ABCpdf.Doc theDoc2 = new Doc();
ABCpdf.Doc theDoc3 = new Doc();
ABCpdf.Doc theDoc4 = new Doc();


int theID = 0, thID1=0, theCount = 0, i = 0;

//Header html
string theText1 = string.Empty;
string theText2 = string.Empty;
string theText3 = string.Empty;
theText1 = this.GetHTML(GetAbsoluteURI("~/headerwithhtml.htm", "", false), "TDR");
theText2 = this.GetHTML(GetAbsoluteURI("~/test2.htm", "", false), "TDR");
theText3 = this.GetHTML(GetAbsoluteURI("~/SampleDocument.htm", "", false), "TDR");

//Header logo
XImage theImg = new XImage();
theImg.SetFile(Server.MapPath("../HTMLToPDF/logo.jpg"));

/*Start Content*/
string test = "Add Text to First Document";
int theFont1 = theDoc1.EmbedFont("Comic Sans MS", "Latin", false, true);
int theFont2 = theDoc1.EmbedFont("Comic Sans MS", "Latin", false, true);

test = "" + test + "";
test = test.Replace("", "");
test = test.Replace("
", "");

string teststring = "Add Text to Second Document";

int theFont3 = theDoc2.EmbedFont("Comic Sans MS", "Latin", false, true);
int theFont4 = theDoc2.EmbedFont("Comic Sans MS", "Latin", false, true);

teststring = "" + teststring + "";
teststring = teststring.Replace("", "");
teststring = teststring.Replace("
", "");


theDoc.Rect.String = "50 50 560 680";
theID = theDoc.AddHtml(theText2);
while (theDoc.Chainable(theID))
{
// theDoc.Page = theDoc.AddPage();
theID = theDoc.AddHtml("", theID);
}

//XReadOptions xr = new XReadOptions();
//xr.ReadModule = ReadModuleType.OpenOffice;

theDoc1.Rect.String = "50 50 560 680";
//theDoc1.FontSize = 8;
thID1 = theDoc1.AddHtml(theText3);
/*
* Loop till there are more pages in the output
*/
while(theDoc1.Chainable(thID1))
{
theDoc1.Page = theDoc1.AddPage();
thID1 = theDoc1.AddHtml("", thID1);
}
//theDoc2.Read("test5.rtf", xr);
//theDoc3.Read("test4.rtf", xr);
//theDoc4.Read("test5.rtf", xr);


//theDoc1.Pos.X = 100;
//theDoc1.Pos.Y = 20;
// theDoc1.Rect.Position(70, -1000);


//theDoc1.AddHtml(test);

//theDoc2.Pos.X = 200;
//theDoc2.Pos.Y = 100;
//theDoc2.AddHtml(teststring);

//theDoc.Append(theDoc1);
//theDoc.Append(theDoc2);
//theDoc.Append(theDoc3);
theDoc.Append(theDoc1);
theCount = theDoc.PageCount;

/*End Content*/

/*Start header*/
theDoc.HPos = 0.5;
theDoc.VPos = 0.5;
for (i = 1; i <= theCount; i++)
{
theDoc.PageNumber = i;
//this loop set header on odd pages
if (theDoc.PageNumber % 2 != 0)
{
theDoc.Rect.Left = 60;
theDoc.Rect.Right = 250;
theDoc.Rect.Top = 10;
theDoc.Rect.Bottom = 725;
theDoc.Rect.Width = 60;
theDoc.Rect.Height = 60;
theDoc.AddImageObject(theImg, false);
theID = theDoc.AddImageObject(theImg, false);
while (theDoc.Chainable(theID))
{
theID = theDoc.AddImageObject(theImg, false);
}
theDoc.Rect.String = "90 780 560 670";
theDoc.FontSize = 8;
theID = theDoc.AddHtml(theText1);
/*
* Loop till there are more pages in the output
*/
while (theDoc.Chainable(theID))
{
theID = theDoc.AddHtml("", theID);
}
theDoc.Rect.String = "30 -40 106 100";
theDoc.FontSize = 8;
theDoc.AddText("Confidential to Ebix");

}
else
{



}

}
/*end header*/


/*Start footer "100 50 500 150";*/
theDoc.Rect.String = "570 -40 300 100";
theDoc.HPos = 1.0;
theDoc.VPos = 0.5;
theDoc.FontSize = 8;
for (i = 1; i <= theCount; i++)
{
theDoc.PageNumber = i;
theDoc.AddText("Page " + i.ToString() + " of " + theCount.ToString());
//theDoc.FrameRect();
}

/*end footer*/

/*Save file as PDF*/

string path = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "Headerfooter.pdf";
if (File.Exists(path))
{
File.Delete(path);
theDoc.Save(Server.MapPath("headerfooter.pdf"));
theDoc.Clear();

}
else
{

theDoc.Save(Server.MapPath("headerfooter.pdf"));
theDoc.Clear();

}

}
}

private string GetHTML(string url, string resourceName)
{
try
{
StringBuilder content = new StringBuilder();

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

using (StringWriter writer = new StringWriter(content))
{
using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
{

writer.Write(reader.ReadToEnd());
reader.Close();
}

writer.Close();
}

return content.ToString();
}
catch (Exception ex)
{
throw ex;
}
}



public string GetAbsoluteURI(string virtualPath, string queryString, bool useSecure)
{
try
{
string path = VirtualPathUtility.ToAbsolute(virtualPath);
Uri newUri = new Uri(HttpContext.Current.Request.Url, path);

UriBuilder uriBuilder = new UriBuilder(newUri);

if (!string.IsNullOrEmpty(queryString))
{
if (queryString.StartsWith("?")) queryString = queryString.Substring(1);
uriBuilder.Query = queryString;
}

if (!useSecure)
{
uriBuilder.Scheme = "http";
if (uriBuilder.Port == 443) uriBuilder.Port = 80;
}

return uriBuilder.Uri.ToString();
}
catch
{
return string.Empty;
}
}


}

GET Fetch Data USing Adaperter with input parameter.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ABCpdf = WebSupergoo.ABCpdf7;
using WebSupergoo.ABCpdf7;
using System.Net;
using System.IO;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

public partial class Headerfooter : System.Web.UI.Page
{

Pdfgenration ObjPdf = new Pdfgenration();

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{


string HtmlString = string.Empty;
string strfileName = string.Empty;
StringBuilder strHtml = new StringBuilder();
string dbstring = ConfigurationManager.AppSettings["DB_WEBGRID_CON_STRING"].ToString();
SqlConnection sqlcon = new SqlConnection(dbstring);
sqlcon.Open();

if (sqlcon.State.ToString() == "Open")
{
SqlCommand command = new SqlCommand("Sproc_POL_INSTALLMENT_BOLETO", sqlcon);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Boleto_ID", SqlDbType.Int).Value = 821;
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds);
HtmlString = ds.Tables[0].Rows[0]["BOLETO_HTML"].ToString();
string Customer_ID = ds.Tables[0].Rows[0]["CUSTOMER_ID"].ToString();
string Policy_ID = ds.Tables[0].Rows[0]["POLICY_ID"].ToString();
string Installement_ID = ds.Tables[0].Rows[0]["INSTALLEMT_ID"].ToString();
string Boleto_ID = ds.Tables[0].Rows[0]["BOLETO_ID"].ToString();
strfileName = Customer_ID + "_" + Policy_ID + "_" + Installement_ID + "_" + Boleto_ID+".pdf";


}

string strPath = "../HTMLToPDF"+ConfigurationManager.AppSettings["PDFDocumentsPath"].ToString();

//string path = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + Filename;

string strLocation = Server.MapPath(strPath) + strfileName;
if (!Directory.Exists(Server.MapPath(strPath)))
Directory.CreateDirectory(Server.MapPath(strPath));
ObjPdf.GeneratePdf(HtmlString, strfileName, strLocation);

//if (!File.Exists(strPath))
//{
// File.Create(strPath);
// ObjPdf.GeneratePdf(HtmlString, strfile, strPath);
//}
//else
//{
// File.Delete(strPath);
// ObjPdf.GeneratePdf(HtmlString, strfile, strPath);
//}
}


}


}

Thursday, November 18, 2010

get file extension

using System;
using System.IO;

class Program
{
static void Main()
{
string p = @"C:\Users\Sam\Documents\Test.txt";

string e = Path.GetExtension(p);
if (e == ".txt")
{
Console.WriteLine(e);
}
}
}

Wednesday, November 10, 2010

querystring in asp.net

This is the Way to Send data one Page from other using QueryString

Page1

protected void Button_Click(object sender, EventArgs e)
{
int ID = 10;
string name = "SHASHI";
Response.Redirect("Default1.aspx?id="+ID+"&name="+name);
}
Page2

protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString[0] != null && Request.QueryString[1] != null)
{
/* string id = Request.QueryString[0].ToString();
string name = Request.QueryString[1].ToString();
*/
string id = Request.QueryString["id"].ToString();
string name = Request.QueryString["name"].ToString();


Response.Write(id + "
" + name);
}
}

Wednesday, November 3, 2010

Reflection

http://www.codeproject.com/KB/cs/C__Reflection_Tutorial.aspx

Tuesday, November 2, 2010

Basics in c#,wpf.Xml

http://www.c-sharpcorner.com/Beginners/

Friday, October 29, 2010

Constructor in c#

http://www.codeproject.com/KB/dotnet/ConstructorsInCSharp.aspx

Generic examples...

http://dotnetperls.com/list

new features of .net framework

http://www.dotnetspider.com/resources/4383-Dot-Net-Framework-Features.aspx

Thursday, October 28, 2010

WCF Article

http://www.aspnet101.com/2010/08/windows-communication-foundation-wcf-tutorial/

Thursday, August 5, 2010

Spliting Dataset Rows in C#

DataTable dtProcess = ObjAudit.GetUserNamebyAuditID(result).Tables[1];
string process = "";
for (int i=0;i {
if (process.Length > 0)
process += ","+ dtProcess.Rows[i]["ProcessName"].ToString();
else
process += dtProcess.Rows[i]["ProcessName"].ToString();

}

Wednesday, August 4, 2010

Read and format XML data into HTML

source from
http://www.java2s.com/Code/ASP/XML/ReadandformatXMLdataintoHTML.htm

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>




Processing the Data in an XML File










<%--




Nancy
Lee

Seattle
WA
98122



Jason
Wang

Vancouver
WA
98123



--%>

Remove Cache.

private void clearCache()
{
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("cache-control", "no-store, no-cache, must-revalidate");
Response.Expires = -1;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
}

Sunday, August 1, 2010

NEW and Override

Data is collected from internet

shadowing :- This is a VB.Net Concept by which you can provide a new implementation for the base class member without overriding the member. You can shadow a base class member in the derived class by using the keyword "Shadows". The method signature,access level and return type of the shadowed member can be completely different than the base class member.

Hiding : - This is a C# Concept by which you can provide a new implementation for the base class member without overriding the member. You can hide a base class member in the derived class by using the keyword "new". The method signature,access level and return type of the hidden member has to be same as the base class member.Comparing the three :-

1) The access level , signature and the return type can only be changed when you are shadowing with VB.NET. Hiding and overriding demands the these parameters as same.

2) The difference lies when you call the derived class object with a base class variable.In class of overriding although you assign a derived class object to base class variable it will call the derived class function. In case of shadowing or hiding the base class function will be called.

________________________________________
There are two main Differences between Shadowing and Overriding.
1) Overriding redefines only the implementation but shadowing redefines the whole Element.
2)In Overriding dervied Class can refer the Base class using ME Keyword but in shadowing we can access it using "MYBase".


Posted by: Praveen Sundar P.V

Contact Praveen Sundar P.V
________________________________________
Shadowing: It hides a base class member in the derived by using the "New" keyword.
It is used to explicitly hide a member inherited from base class.
new and override both cannot be used for the same member.

eg:-
class Employee
{
public virtual double CalculateSalary()
{
return basic_salary;
}
}
class SalesPerson: Employee
{
double sales,comm;
public new double CalculateSalary()
{
return basic_salary+(sales*comm);
}
}
static void main(string[] args)
{
SalesPerson sal=new SalesPerson();
double s=sal.CalculateSalary();
Console.WriteLine(s);
}

Overriding:In this methods have same names,same signatures,same return types but in different classes.
C# uses virtual and override keyword for method overriding.

eg:-
class Employee
{
public virtual double CalculateSalary()
{
return basic_salary;
}
}
class SalesPerson: Employee
{
double sales,comm;
public override double CalculateSalary()
{
return basic_salary+(sales*comm);
}
}
static void main(string[] args)
{
Employee sal=new SalesPerson();
double s=sal.CalculateSalary();
Console.WriteLine(s);
}

When you call the derived class object with a base class variable.In class of overriding although you assign a derived class object to base class variable it will call the derived class function. In case of shadowing or hiding the base class function will be called

Wednesday, July 28, 2010

how to File Download file of any extension

protected void grdauditDocumentDetail_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Del")
{
pclsAuditDocumentsqlDL obj = new pclsAuditDocumentsqlDL();
clsAuditDocumnetSqlBL objAuditDoc = new clsAuditDocumnetSqlBL();
int Docid = Convert.ToInt32(e.CommandArgument);
// Convert.ToInt32((row.FindControl("lblDocid") as Label).Text);
objAuditDoc.DeleteAuditDocbyAuditDocid(Docid);
fillgrdAuditDetail();
lblMsg.Text ="Record Deleted Successfully!";


}
if (e.CommandName == "Download")
{
Downolad(e.CommandArgument.ToString(), System.IO.Path.GetExtension(e.CommandArgument.ToString()));
}


}

private void Downolad(string filename, string ext)
{
string type = "";
switch (ext.ToLower())
{
case ".htm":
case ".html":
type = "text/HTML";
break;

case ".txt":
type = "text/plain";
break;

case ".doc":
case ".rtf":
type = "Application/msword";
break;

case ".jpg":
case ".jpeg":
type = "Application/jpg";
break;

case ".xls":

type = "Application/xls";
break;
case ".pdf":

type = "Application/pdf";
break;
}

long FileSize;
string path = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + ConfigurationManager.AppSettings["AuditDocumentspath"] + "/" + filename;
if (File.Exists(path))
{
System.IO.FileStream MyFileStream = new System.IO.FileStream(path, System.IO.FileMode.Open);
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize + 1];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType = "application/" + type;
Response.AddHeader("content-disposition", "attachment; filename=" + filename + ";");
Response.BinaryWrite(Buffer);
Response.End();
}
else
{
MessageBox.Show(this, "File Does not exist in Directory!");
}


}

Saturday, July 24, 2010

Listbox options javascript select all,move left-right, move up-down

Listbox options javascript select all,move left-right, move up-down

http://viralpatel.net/blogs/2009/06/listbox-select-all-move-left-right-up-down-javascript.html


Select content from one list to another using jQuery


http://www.akchauhan.com/select-content-from-one-list-to-another-using-jquery/

jquery cool examples,realy nice

http://web.enavu.com/tutorials/top-10-jquery-snippets-including-jquery-1-4/

http://www.devx.com/getHelpOn/10MinuteSolution/16372/1954

http://www.techinterviews.com/javascript-interview-questions-and-answers

Wednesday, July 21, 2010

Radio App

http://www.codeproject.com/KB/WPF/fmradio.aspx

api finder/tokbox c# api

http://www.apifinder.com/APIFinder/APIDisplay/29771

http://code.google.com/p/tokboxapi/downloads/list

Monday, July 19, 2010

Delegates in C#

Delegates in C#

Most programmers are used to passing data in methods as input and output parameters.
Imagine a scenario where you wish to pass methods around to other methods instead of data. Amazed! Read further.



Sponsored Links



Consider a scenario where you need to make a ‘business decision’ in your program, to make a decision you need data. To get data you need to call a method. However the method name is not known at design time. It will only be known at run time.

In this case you need to pass the unknown method as a parameter. The method that you are passing in is known as a Callback function. Call back functions are pointers to methods.

.NET implements the concept of function pointers using delegates.

* Delegate wraps a method. Calling delegate results in calling the method.
* Delegate is a type of object very similar to classes.
* Delegate gives a name to a method signature.

Where are Delegates used?

The most common example of using delegates is in events.

You define a method that contains code for performing various tasks when an event (such as a mouse click) takes place.

This method needs to be invoked by the runtime when the event occurs. Hence this method, that you defined, is passed as a parameter to a delegate.

Source from
http://www.exforsys.com/tutorials/csharp/delegates-in-csharp.html

C# Multicast Delegates - A Practical Example


Location: BlogsNetSplore's Blog
Posted by: Joe Rattz 11/23/2006 4:04:44 AM
The C# language has a feature known as the multicast delegate. Any delegate that has a void return type, is a multicast delegate. A multicast delegate can be assigned and invoke multiple methods.

You may have seen hints of this in your code. For example, if you are doing ASP.NET development and have ever looked at a page's InitializeComponent() method, you may have noticed a statement like this:

this.SearchButton.Click += new System.EventHandler(this.SearchButton_Click);

Notice the += in that statement. That is a clue. You could add another event handler if you wanted, and it would get called as well. For example, let's say you wanted to also call a method named NotifyStatistics every time the Search button was clicked. Then your code could be:

this.SearchButton.Click += new System.EventHandler(this.SearchButton_Click);
this.SearchButton.Click += new System.EventHandler(this.NotifyStatistics);

Every time the user clicks the Search button, first SearchButton_Click() is called, followed by NotifyStatistics(). The event handlers are called in the order they are added. Likewise, using -=, an event handler can be removed.

Now, you may be asking, why not just add whatever code is in the NotifyStatistics method to the SearchButton_Click method?

source from
http://www.netsplore.com/PublicPortal/blog.aspx?EntryID=9


Difference Between Delegates and Interfaces
You use delegates when you think of a .NET code that takes callback parameters, which look a lot like strongly typed method pointers in C++. You may not think that you can implement a callback parameter as an interface. Interfaces and delegates have a common key property of allowing you to call a method with the right prototype without knowing which object implements the method, which instance is bound to the call, or the name of the method you're calling.
1. Interface calls are faster than delegate calls. An interface reference is a reference to an instance of an object which implements the interface. An interface call is not that different from an ordinary virtual call to a method. A delegate reference, on the other hand, is a reference to a list of method pointers. While invoking a delegate looks like you're making an indirect call through a method pointer, it's actually a subroutine call that walks the list of method pointers. The overhead involved in making the call and walking the list means that delegate invocation can be two or three times slower than calling a method through an interface reference.
2. Interfaces are also a bit more general than are delegates. A single interface reference gives you access to all the methods of the interface. You can also check if the interface is implemented by this object type, or if the object also implements that other interface. If it does, you can cast the interface reference to an instance reference, or to a reference to another interface. Conversely, you can not go from a delegate to the instances it will call or to any other methods those instances may support.
However, don't conclude from this that you should always implement callbacks via interfaces, not delegates. One key difference between delegates and interfaces is that you can create a delegate to any method with the right prototype.
Overriding….
http://stackoverflow.com/questions/392721/difference-between-shadowing-and-overriding-in-c

http://www.noupe.com/tutorial/51-best-of-jquery-tutorials-and-examples.html
http://www.tutorialspoint.com/javascript/javascript_builtin_functions.htm

Sunday, May 30, 2010

show hide prompt msg.



protected virtual void ShowMsg(Label labelName, string strMsg)
{
labelName.Text = strMsg;
StringBuilder sb = new StringBuilder();
sb.Append("");
ClientScript.RegisterStartupScript(GetType(), "ss", sb.ToString());
}

//javascript

function fadeIn(id, steps, duration, interval, fadeOutSteps, fadeOutDuration) {
for (i = 0; i <= 1; i += (1 / steps)) {
setTimeout("setOpacity('" + id + "', " + i + ")", i * duration);
fadeInComplete = i * duration;
}
//set the timeout to start after the fade in time and the interval to display the
//message on the screen have both completed
setTimeout("fadeOut('" + id + "', " + fadeOutSteps + ", " + fadeOutDuration + ")", fadeInComplete + interval);

}

function fadeOut(id, steps, duration) {
var fadeOutComplete;
for (i = 0; i <= 1; i += (1 / steps)) {
setTimeout("setOpacity('" + id + "', " + (1 - i) + ")", i * duration);
fadeOutComplete = i * duration;
}
//completely hide the displayed message after the fade effect is complete
setTimeout("hide('" + id + "')", fadeOutComplete);
}

function hide(id) {
document.getElementById(id).style.display = 'none';
}

Wednesday, April 28, 2010

good editors

http://sourceforge.net/projects/tinymce/files/TinyMCE/3.3.4/tinymce_3_3_4.zip/download
//for refreshing the Gridview use hidden button ,which will refresh the grid automatically.

function btnClick() {
var btn = '<%=btnrefresh.ClientID%>';
document.getElementById(btn).click();
}



//for refreshing page
location.reload();

throw child page values to parent page.

//use this js function on parent page ]


string script = "";
Page.RegisterStartupScript("Close", script);

Saturday, April 3, 2010

WPF Learning ...use below link

http://en.csharp-online.net/WPF_Styles_and_Control_Templates%E2%80%94Element-Typed_Styles

Wednesday, March 31, 2010

check/uncheck treeview node

source from
http://pushpontech.blogspot.com/2007/06/treeview-checkuncheck-all-script.html