asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Accessing Caller ID from the Web - Part 3
By Paul Apostolos
Rating: 3.1 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article


    Part one dealt with building a VB6 program to update a SQL Server database with incoming caller id information. Part two focused on building a Web service that exposes methods for reading and manipulating the caller id data. This part will show how to configure a proxy class for accessing the Web service and build an ASP.NET page to deliver the caller id information to the Web.

    The easiest way to use this Web service is by using Visual Studio .NET (VS .NET) to write the page or application that will consume the service. With VS .NET it is as easy as right clicking on the references folder in the solution explorer and choosing "Add Web reference". All that's left is to key in the url of the Web service--in this case http://www.allpaul.com/service.asmx--and after I click the Add Reference Button, Viola! The Web service is ready for use. In fact, the intellesense in VS .NET even works like you'd expect for objects created via the Web reference.

    In this case though, I opted for a far more complicated but less expensive (as it only involves the free .NET SDK download not the full version of Visual Studio.NET) way to create the proxy that is needed to consume the Web service--using the command line and a few tools included in the .NET SDK.

    Open a command window and navigate to the install path of the .NET sdk. In my case it is C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705. From there run the two tools to create the proxy. The first, wsdl.exe, to generate a VB.NET soucre file.

    
    wsdl /language:VB http://www.allpaul.com/service.asmx?WSDL
    
    
    The tool produces a VB source file based on the name of the class it is describing. In this case the file Caller_Id.vb was produced. That's not the end of the command line story though. We still need to compile the VB source file. To do that we'll use the Visual Basic .NET compiler vbc.exe from the same command window.
    
    vbc /t:library Caller_Id.vb 
    /r:System.Web.dll,System.dll,System.Web.Services.dll,System.Xml.dll,System.Data.dll
    
    
    The /t switch tells the compiler what type of file to produce. In this case a library or .dll is specified. The /r switch indicates which assemblies to reference. There are a number of switches for this tool. To see a complete list type vbc /?.

    That's it for the proxy...Well, almost. I still need to put the resulting .dll in to the bin directory of my application.

    The Output

    Use a data list to display the list of callers. And, since the Web service method Get_Callers returns a Data Set, simply bind that data set to the data source property of the data list. My sub Bind() illustrates this: Sub Bind()

    
    	Dim myWebSvc as Caller_Id = New Caller_Id()
    
    	Dim ds as DataSet
    
    	ds = myWebSvc.Get_Callers()
    
    	Caller_List.DataSource= ds.Tables("tbl_Caller_Id").DefaultView
    	Caller_List.DataBind()
    
    End Sub
    
    
    The data list is not your ordinary out of the box data list though.

    We haven't even scratched the surface of the functionality of the data list or dataset in this example. These are a few simple ideas for formatting output and handling events. The desired output is

    Call_Name (Name or business name of the caller) Call_Number (The phone number from where the call originated) Call_Date (Date and time the call was received)

    We also want to link the Call_Number to a reverse directory assistance Web site so that we can find out more information about the caller than is provided from the caller id info.

    So, the first line of the data list shows the data list declaration and sets a few properties. Most notable is the OnItemCommand property, which is set to handle only deleting of individual records, but could be used to handle editing as well.

    Next, let's start laying out the presentation of the data list by using an ItemTemplate. The first element of the template is a label to display the Caller_Name item from the dataset.

    
    <asp:Label id="Caller_Name" class="contents" Text='<%# Container.DataItem("Call_Name") %>'
     runat="server" />
    
    
    By binding (The #) the Text property of the label to the Caller_Name item from the dataset, we achieve the first line of the desired output.

    But, we would also like to delete callers from the list. To do that, we add a linkbutton and set its CommandName property to delete. If we were using other commands, we would have to handle the Caller_List_ItemCommand sub a little differently, but for simplicity, we're only going to handle one ItemCommand with it.

    
    <asp:linkbutton id="b1" runat="server" Text="Delete" CommandName = "delete" />
    
    
    All right. Next we want to display the Call_Number. Mentioned earlier was functionality to link to some reverse phone number lookup on the Web in order to find out more information about the caller. The service I found is www.infousa.com. In order to directly link to the lookup feature of their Web site, we need to use this really long convoluted Url:

    http://adp.infousa.com/fs?BAS_fssession=&BAS_vendor=0&bas_type=FADA&BAS_page=9&DAT_max records=10&BAS_flag=2&BAS_flag2=1&SCH_origdb=FADP&sch_fullph one=Call_Number

    I should also qualify this by saying that there are many of these services on the Internet and most of them are free. And, this one, like all the others, isn't 100% reliable. For instance if the caller has an unlisted or new phone number, most likely there will be no information found. That said, use the hyperlink element to display the phone number and link it to the directory service:

    
    <asp:hyperlink id="Caller_Number" class="contents" Text=''
                  runat="server" NavigateURL='' />
    
    
    By setting the NavigateURL property to the desired hyperlink and appending the Call_Number to the end of the link, we achieve the desired results.

    The final line is similar to the the Call_Name line. I use a label element and bind its Text property to the Call_Date item from the dataset.

    
    <asp:Label id="Caller_Date" class="contents" Text='' runat="server" />
    
    

    Putting It All Together

    The complete source code for this part of the project can be found below. Hopefully, this application will be as useful for you as it has been for me and my family. Good luck!

    
    <%@ Import Namespace = "System.Data" %>
    <script language="vb" runat="server">
    
    Sub Page_Load()
    	
    	If Not Page.IsPostBack Then
    		Bind()
    	End if
    	
    End Sub
    
    Sub Bind()
    
    	Dim myWebSvc as Caller_Id = New Caller_Id()
    
    	Dim ds as DataSet
    
    	ds = myWebSvc.Get_Callers()
    
    	Caller_List.DataSource= ds.Tables("tbl_Caller_Id").DefaultView
    	Caller_List.DataBind()
    
    End Sub
    
    
    
    Sub Caller_List_ItemCommand(Sender As Object, e As Data listCommandEventArgs)
    
    	Dim myWebSvc as Caller_Id = New Caller_Id()
    	myWebSvc.Delete_Caller(Caller_List.DataKeys(e.Item.ItemIndex))
    	Trace.Write(Caller_List.DataKeys(e.Item.ItemIndex))
    	Bind()
    	
    End sub
    
    </script>
    
    
    <h4>Caller Id Calls</h4>
    
    <form runat="Server">
    <asp:Data list runat="server" id="Caller_List" DataKeyField="ID" 
    OnItemCommand="Caller_List_ItemCommand">
    	<ItemTemplate>
    	  <asp:Label id="Caller_Name" class="contents" Text='<%# 
    Container.DataItem("Call_Name") %>' runat="server" />  
              <asp:linkbutton id="b1" runat="server" Text="Delete" CommandName 
    = "delete" /><br>
    	  <asp:hyperlink id="Caller_Number" class="contents" Text='<%# 
    Container.DataItem("Call_Number") %>'
                  runat="server" NavigateURL='<%# 
    "http://adp.infousa.com/fs?BAS_fssession=&BAS_vendor=0&bas_type=FADA&BAS_page=9 
    _
                  &DAT_maxrecords=10&BAS_flag=2&BAS_flag2=1&SCH_origdb=FADP&sch_fullphone= _
                  " & (DataBinder.Eval(Container.DataItem,"Call_Number")) %>' 
    /><br>
      	  <asp:Label id="Caller_Date" class="contents" Text='<%# 
    Container.DataItem("Call_Date") %>'
                  runat="server" /><br><br>
    	</ItemTemplate>
    </asp:Data list >
    </form>
    
    

    About the Author

    Paul Apostolos is Director of Internet Development for the National Roofing Contractors Association (www.nrca.net). Paul has more than 5 years experience programming and developing Web sites based on Microsoft technologies. He can be reached at paul@allpaul.com.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Other Articles
    Apr 21, 2005 - Building a FAQ Module for the ASP.NET Community Starter Kit
    This sample chapter from Packt Publishing's "Building Websites with the ASP.NET Community Starter Kit" illustrates how to build a new module on top of the existing code in the ASP.NET Community Starter Kit (CSK). Using a Frequently Asked Questions (FAQ) module as an example, it shows how creating a new module allows you to add entirely new features which integrate seamlessly with the rest of the framework.
    [Read This Article]  [Top]
    Oct 20, 2004 - Beyond the DataGrid: An Architectural View of the Data Source Model in ASP.NET 1.x and 2.0
    Dino Esposito discusses the differences between the DataGrid control in version 1.x and 2.0 of ASP.NET. In the process, he also builds an improved version of the 1.x control that can get you some of the new 2.0 features today.
    [Read This Article]  [Top]
    Aug 25, 2004 - Developing Web Parts with the ICellProvider Interface
    Most default SharePoint Server Web Parts can be connected across organizations. The second article in this series shows how to develop connectable Web Parts that provide information to other Web Parts.
    [Read This Article]  [Top]
    Aug 4, 2004 - Accessibility Improvements in ASP.NET 2.0 - Part 2
    Alex Homer continues to highlight some of the new ASP.NET 2.0 accessibility features. These features make it easier for visually impaired users to view and navigate Web sites and provide better support for alternative types of browsers and user agents.
    [Read This Article]  [Top]
    Jul 30, 2004 - Connectable Web Parts in SharePoint Portal Server 2003 - Part 1
    Most default SharePoint Server Web Parts can be connected across organizations. The first article in this series explains how to connect existing Web Parts using the connection Interface classes in the SharePoint architecture.
    [Read This Article]  [Top]
    Jul 27, 2004 - Accessibility Improvements in ASP.NET 2.0 - Part 1
    Alex Homer highlights some of the new ASP.NET 2.0 accessibility features. These features make it easier for visually impaired users to view and navigate Web sites and provide better support for alternative types of browsers and user agents.
    [Read This Article]  [Top]
    Jun 30, 2004 - Simplified and Extended Data Binding Syntax in ASP.NET 2.0
    Alex Homer discusses the simplification of, and extensions to, the ASP.NET 1.x data binding syntax, the new two-way data binding syntax for updating data sources, and the new syntax for binding to XML data in ASP.NET 2.0.
    [Read This Article]  [Top]
    May 18, 2004 - ASP.NET 2.0 Caching Features
    This article examines some of the new and exciting caching features in ASP.NET 2.0 and shows how to implement them in Web applications.
    [Read This Article]  [Top]
    May 11, 2004 - SharePoint Security and .NET Impersonation
    When implementing custom components that require access to restricted resources, implicit impersonation must be used. Jay Nathan shows how to create a class that makes using .NET Impersonation a snap.
    [Read This Article]  [Top]
    May 4, 2004 - Creating a Flexible Configuration Section Handler
    Jeff Gonzalez demonstrates how to create a flexible configuration section handler using C#. He provides a summary background of the .NET configuration system, explains why the system is useful, and shows how it can be extended.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info

    Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers