How to: Use the RealTimeSearchMonitor Extender
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This topic describes how to use the RealTimeSearchMonitor control. This control allows ASP.NET developers to implement real-time search without writing custom client-side code. For more information about this control, see RealTimeSearchMonitor Control.
To use the RealTimeSearchMonitor, you must have a Web site or Web application project that meets the following conditions:
- It has been configured to target the Microsoft .NET Framework 3.5.
The Web page that you want to add real-time search capabilities to must have at least one search input control and must contain an UpdatePanel control where the search results are displayed.
The following procedure describes how to use the RealTimeSearchMonitor control to add real-time search capabilities to a search form.
To use the control
- In your Web site, add a reference to the RealTimeSearch.dll assembly.
- Add the RealTimeSearchMonitor control to the Toolbox (this step is necessary only if you do not see the RealTimeSearchMonitor control in the Toolbox). To add the RealTimeSearchMonitor control to the Toolbox, right-click the Toolbox, and then click Choose Items. On the .NET Framework Components tab, click Browse, select the RealTimeSearch.dll assembly, and then click Open. In the list of components, select the RealTimeSearchMonitor control, and then click OK.
- Drag a RealTimeSearchMonitor control to the Web page to which you want to add real-time search capabilities.
- Open the Properties window for the control, as shown in Figure 1.
- Enter the ID of the UpdatePanel control where the search results are displayed in the AssociatedUpdatePanelID property.
- Click the ellipsis in the ControlsToMonitor property to open the collection editor, as shown in Figure 2.
- For each input control that you want to be monitored, click Add and set the following properties:
- TargetId. This is the ID of the input control to be monitored
- (Optional) EventName. This is the name of the event of the input control that triggers an update in the associated UpdatePanel control. If no value is specified for this property, the default event of the control will trigger the update.
Note: Note: The RealTimeSearchMonitor control adds an AsyncPostBackTrigger to the associated UpdatePanel control at run time for each monitored control. The EventName property of the AsyncPostBackTrigger is set with the value you enter in the EventName property of the control to monitor.
- Click OK to close the collection editor.
- Set the Interval property. The Interval property defines how often (in milliseconds) the input control is checked to see if the value has changed.
The following code extracted from the Real-Time Search QuickStart shows the markup of a fully configured RealTimeSearchMonitor control.
<rts:RealTimeSearchMonitor ID="CustomerRealTimeSearchMonitor" runat="server" Interval="700" AssociatedUpdatePanelID="ResultsUpdatePanel"> <ControlsToMonitor> <rts:ControlMonitorParameter TargetId="CompanyNameTextBox" /> <rts:ControlMonitorParameter TargetId="CityTextBox" /> <rts:ControlMonitorParameter TargetId="StateDropDown" /> <rts:ControlMonitorParameter TargetId="ZipCodeTextBox" /> </ControlsToMonitor> </rts:RealTimeSearchMonitor>
- Add event handlers for the input controls’ events that you want to monitor, and implement them in the code-behind file of your Web page. In the event handlers, you should execute the search query and display the result set inside the associated UpdatePanel control.
Note: Note: Typically, you subscribe to the TextChanged event of TextBox controls.
|Note: The RealTimeSearchMonitor control invokes the validators of the monitored controls before performing an asynchronous postback. If the validation fails for any of the input controls, the postback is not done.|