Can you explain the concept of triggers in ‘UpdatePanel’ control?

 Posted by ArticlesMaint on 10/1/2009 | Category: ASP.NET AJAX Interview questions | Views: 8804

Triggers are child tags for ‘UpdatePanel’ tag. Many times we would like to update the panel when some event occurs or a value change on a control. This can be achieved by using triggers. There are two types of triggers ‘ControlEventTrigger’ and ‘ControlValueTrigger’. So let’s first understand ‘ControlEventTrigger’. Using ‘ControlEventTrigger’ we define on which control and at which event the update panel should refresh. Below is a simple code snippet for ‘ControlEventTrigger’. ‘ControlEventTrigger’ are defined using ‘<atlas:ControlEventTrigger>’ tag. We have numbered the code snippet below so let’s understand the same with numbers:-

  • 1 -> We need to define ‘ControlEventTrigger’ using ‘<atlas:ControlEventTrigger>’ tag.

  • 2 -> In this sample we will link trigger in ‘UpdatePanel1’ with the click event of ‘Button1’.

  • 3 -> In the ‘<atlas:ControlEventTrigger>’ tag we need to define the control and event using ‘ControlId’ and ‘EventName’ properties respectively.
    So now when the button click event happens ‘UpdatePanel1’ is refreshed.

Figure 18.12: - Code snippet for ‘ControlEventTrigger’

Using ‘ControlValueTrigger’ we can update a panel when an external control has reached some value. So again we need to define the same in a ‘Triggers’ tag. We need to put the ‘ControlvalueTrigger’ tag with control and property defined using the ‘ControlId’ property. So according to below code snippet when the value of ‘Textbox1’ changes we need to update the top panel.

Figure 18.13:- ‘ControlValueTrigger’ code snippet

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response