Requirement: After the data is saved in the user control, refresh the data list on the host page and asynchronously refresh the data list.
Solution: Click the Save button in the user control to refresh List A on the host page. First, we need to use updatepanel to package list, then, you only need to find a way to refresh the updatepanel after clicking the Save button. However, on the host page, we cannot directly mount the updatepanel triggle with the Save button in the user, even if it can be mounted, however, we still need to use the Save button to update the host page, which is very troublesome. However, as long as the user control can throw an event, we only need to implement this event on the host page to complete the refresh, in addition, updatepanel can be directly linked to the event that the user control runs. As long as this event is triggered by the Save button. Our problem is solved.
How to Create a throw eventCodeAs follows:
Code
// Code in the control
Public Delegate Void Clickeventhandler ( Object Sender, eventargs E );
Public EventClickeventhandler click;
protected void btnsave_click ( Object sender, eventargs e)
{< br> /// here, You can implement your own business and store information in
If (Click ! = null )
{< br> click ( This , e); /// throw this event and execute the event implemented on the host page
}< BR >}
// host page
This . uccompanyinfor. click += New pages_companyprofile_companyinforamtion.clickeventhandler (uccompanyinfor_click );
Protected VoidUccompanyinfor_click (ObjectSender, eventargs E)
{
Bindleftdatasource ();//Refresh the host page list
}
//