Tuesday, February 7, 2012

Using Delegates and Events

test.aspx.cs
void WebUserControl1_btnHandler(string strValue)
    {
        GetDataByAssetId(Convert.
ToInt32(strValue));
    }
 CertificatesSearch1.btnHandler += new ADCO.ePTW.UserControl.CertificateNumber.OnRowCommand(WebUserControl1_btnHandler);


test.ascx.cs

This is the above page load
 // declaration of  Delegate
public delegate void OnRowCommand(string strValue);
// declaration of Event
public event OnRowCommand btnHandler;

 if (btnHandler != null)
       btnHandler(objAssetId.ToString());

Public Void GetDataByAssetId(int id)
{
 //write the logic here

No comments:

Post a Comment

Comments

Protected by Copyscape Plagiarism Software