Monday, December 16, 2013

How to handle button event for user control in asp.net page

A better idea is to publish an event in the user control to allow any interested parties to handle the event.
This technique is commonly referred to as “event bubbling”.
Here is an exmple:
public partial class Test : System.Web.UI.UserControl
{
public event EventHandler buttonClick;
 protected void Button1_Click(object sender, EventArgs e)
    {
        buttonClick(sender, e);
    }
{
    protected void Page_Load(object sender, EventArgs e)
    {
    {
        Response.Write("hello,I am jack.");
    }


}
Then you can subscribe the event buttonClick at webpage to display the different information .
public partial class Test: System.Web.UI.Page
    UserControlID.buttonClick+=new EventHandler(UserControlID_buttonClick);
}
    protected void UserControlID_buttonClick(object sender, EventArgs e)
}

COALESCE function in SQL

The COALESCE function can be used in Oracle/PLSQL.
You could use the coalesce function in a SQL statement as follows:

SELECT COALESCE( address1, address2, address3 ) result FROM suppliers;

The above COALESCE function is equivalent to the following IF-THEN-ELSE statement:
IF address1 is not null THEN
   result := address1;

ELSIF address2 is not null THEN
   result := address2;

ELSIF address3 is not null THEN
   result := address3;

ELSE
   result := null;

END IF;
The COALESCE function will compare each value, one by one.