The provided Stock Quote C# project allows you or your website visitors to get market data for a single stock using Google’s free stock quote API. With some additional development, you can change the source code to retrieve quotes for multiple stock symbols. I’ll leave that up to you.
The Default.aspx page in the ASP.NET solution consists of a TextBox (search field) that allows you to enter a stock symbol for the market security of interest, a Button control to initiate the call to the stock quote API, and a Form control to display the stock data returned from the web service.
In additional, the TextBox control includes “OnClick” and “OnBlur” events implemented using basic JavaScript. If your site visitor clicks inside the search box, the default text automatically clears. If they click away without typing anything, the default text will automatically return. This is a useful technique to improve your user interface design.
If data is found for the stock market symbol, the Form control becomes visible and the applicable data is displayed in the Form. If the stock symbol is not found, a “Not Found Message” is displayed and the Form control will be hidden.
The Google stock quotes web service returns a lot of stock market data. However, the provided project only returns the following market data: Company Name, Exchange, Last Trade, Change, Percent Change, High, and Low. The source code in the C# code-behind page is organized and simple to read. Therefore, you can easily change it to display more data returned from the stock quote API.
You can get the full ASP.NET C# source code for this project by selecting the download link below.
Download Source Code - Get Stock Quotes
