tailieunhanh - Foundations of ASP.NET AJAX phần 10

VE là một ứng dụng trực tuyến hoàn toàn tổ chức và như vậy không yêu cầu thêm bất cứ thành phần trên máy khách để hoạt động đúng. Bao gồm kịch bản bên ngoài trên đầu trang của bạn là tất cả những gì cần thiết để mở cửa cho các chức năng phong phú của VE. Một ngoại lệ cho thực tế này là việc sử dụng bản đồ 3D. | 234 CHAPTER 10 BUILDING A SAMPLE APPLICATION USING AJAX Figure 10-6. Specifying the WSDL The Company Information web service is used in the application to present the name of the company as well as the current price information. Now there needs to be a method called GetCompanyInfo in which we write the code to use a few of the properties to get the actual company data. After that this information needs to be assigned to the IblQuote control as shown in the following code snippet private void GetCompanyInfo string strTicker service new result anything anything strTicker BR Current Price BR Change This function updates the company information pane as well as the price history text and graphs. Also because this is the one piece of information that does not reside within the tabs it should be rendered and updated without the user clicking on the individual tabs. Furthermore the user should be able to enter a new stock ticker in the main CHAPTER 10 BUILDING A SAMPLE APPLICATION USING AJAX 235 TextBox and have the data updated. So to address these points we need to first call the GetCompanyInfo method during the Page_Load event and then create a Timer control. In the control s Tick event handler we call the method shown here protected void Page_Load object sender EventArgs e if GetCompanyInfo Default to first tab Update 0 This way the ticker information is updated in regular intervals and if the user enters a new stock ticker the changes are reflected as soon as the GetCompanyInfo method is called again in 5 seconds . To create a timer for this page drag and drop the ASPNET AJAX Timer control from the Toolbox onto the page and set its Interval property to 5000ms so that the page updates every 5 seconds. Also don t forget to set the event handler for