<html> <head> <script runat=server> // Wire up the onClick event for a button protected void button1_Click(object sender, EventArgs e) { file://Create a object of the class DailyStock (the proxy class) DailyStock ds = new DailyStock();
// Call the GetQuote method of the proxy class DailyStock and // pass the symbol string from the textbox string res = ds.GetQuote(symbol.Text);
// The returned string has values which are separated // by commas. // Hence we split the returned string into parts char[] splitter = {','} ; string[] temp = res.Split(splitter);
// Check if the string array returned has more than one // elements since if there are less than one elements // then an exception must have been returned if(temp.Length >1) { // The WebService returns a lot of information about the // stock. We only show the relevant portions // Set the label to current Index curindex.Text = "Current Index :"+temp[1];
// Set the label to current Date Time curdate.Text ="Last Update on"+temp[2]+" at "+temp[3]; } else { error.Text = "Error :"+res ; file://set the error label } } </script>