TechMela, its all different

TechMela is all different. It is a fusion of technologies, expertise and a cliche of our individual events. We earlier used to have Tech Ed for developers, Mobile and Embedded Developers Conference for all those Mobile Devs and bunch of other events like IT Pro for IT Professionals.

TechMela brings it all to gether. You never miss out even a single topic when you land up at Tech Mela. With over 3 days, 7 Tracks, 150 sessions and 300 labs, it cannot get bigger than this!

TechMela - Business

TechMela also has something for Business folks too, this time. Tech Mela for business is an invitation only event for upto 500 key decision makers to participate and share their views as well as learn how they can monetize on developing using our latest technologies. If you are a Business guy and would need an invitation please visit http://www.techmela.com/business.htm for more information.

TechMela - Technology

Tech Mela for technology, for all you tech guys, it has a whooping 150 Sessions spread across 3 days and you never get exhausted with the flood of new things to learn.

Couple of Quick Facts

TechMela is happening in Mumbai this year

The Dates are 14th - 16th June 2007

For registration and more information, visit http://www.techmela.com/tec_agenda.htm

TechMela Site

http://www.techmela.com is your one stop shop for all information on TechMela.

I am presenting the Web Track and watch out for more information about the Web Track as I prepare for presenting the same.

Cheers !!!

Consuming the Live Search API in your Web Applications - Windows Live

Well, I havent talked much about Windows Live and when the whole world is keen about our Live initiative and the exciting bunch of services we have unveiled, I thought of starting it up, with an article on how you can consume the Live Search API and implement Live Search within your web applications.

Before getting started, there are a few things you would need to know about Live.

Windows Live is a platform.  It is a collection of online services which can be utilized as well as programmed against.  To read more about Live from a Developer perspective, visit http://dev.live.com

I want to divide this article into four sections

1. Creating an Application ID for consuming the Live Service

2. Implementing the Live Search in your Web Application

3. Tip / trick on overcoming against proxies in the above sample

4. Resources for getting started with similar APIs.

Creating an Application ID for consuming the Live Service

Before you could start using the Live Search API, you need an Application ID for being able to query using the Service.  To get the same, visit http://search.msn.com/developer.

Sign in using your passport account (if you have a hotmail / msn.com account its already a passport) so that you can create / manage Application IDs.  If you are using it for the first time, you would have the option to only Create Application IDs.  Specify an Application name and you would be provided with an Application ID which you  must be using in your sample in the Section 2 of this article.  There after you can login to this site and Edit / Delete and manage your Application ID settings.

Implementing the Live Search in your Web Application

Once you have created the Application ID, you are all set for programming the Live Search API and getting results.  For my sample, I have used a simple textbox, Button, Label and a Gridview for displaying results.  Let us see how the ASPX File looks like

<form id="form1" runat="server" defaultbutton="Button1">
    <div>
        <asp:TextBox ID="TextBox1" runat="Server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="Server" Text="Search" OnClick="Button1_Click" />
        <br />
        <hr />
        <asp:Label ID="Label1" runat="Server"></asp:Label>
        <br />
        <br />
        <asp:GridView ID="GridView1" runat="Server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#EFF3FB" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="Title" HeaderText="Title" ControlStyle-Width="30%" />
                <asp:BoundField DataField="Description" HeaderText="Description" ControlStyle-Width="60%" />
                <asp:HyperLinkField DataTextField="Url" HeaderText="URL" ControlStyle-Width="20%" DataNavigateUrlFields="URL" />
            </Columns>
        </asp:GridView>
    </div>
    </form>

In this sample, I am binding the Title, Description as well as the URL Fields.  But there are more fields which you may want to bind to.  You can keep adding BoundFields to the above Columns collection of the GridView to add more fields.

The Next step is to consume the Live Search Web Service.

The WSDL for the Search Service is http://soap.search.msn.com/webservices.asmx?wsdl.

Add Web Reference to your Website with the above WSDL.  The default Web Reference is com.msn.search.soap, but you can change it as per your wish.  However, this name should be referred in the Code behind file under the name space declarations.

Once you are done adding the web reference, go to the above ASPX Page - design view and double click on the "Search" button to generate the Button Click event.

Go to the Code behind and in the name space declarations, add the following namespaces:-

using System.Web.Services.Protocols;
using com.msn.search.soap;
using System.Net;

Go to the Button Click event and add the following code:-

 try
        {
            MSNSearchService s = new MSNSearchService();
            SearchRequest searchRequest = new SearchRequest();
            int arraySize = 1;
            SourceRequest[] sr = new SourceRequest[arraySize];

            sr[0] = new SourceRequest();
            sr[0].Source = SourceType.Web;

            searchRequest.Query = TextBox1.Text;
            searchRequest.Requests = sr;
 
           searchRequest.AppID = "APP ID you generated from http://search.msn.com/developer";
            searchRequest.CultureInfo = "en-US";
            SearchResponse searchResponse;

            searchResponse = s.Search(searchRequest);

            foreach (SourceResponse sourceResponse in searchResponse.Responses)
            {
                Result[] sourceResults = sourceResponse.Results;
                if (sourceResponse.Total > 0)
                {
                    Label1.Text = sourceResponse.Source.ToString() + " - Total Results: " + sourceResponse.Total.ToString();
                }
                GridView1.DataSource = sourceResults;
                GridView1.DataBind();
        }
        catch (SoapException ex)
        {
            Response.Write(ex.Message);
        }
        catch (WebException ex)
        {
            Response.Write(ex.ToString());
        }

In the above sample,  replace the App ID comment with the actual Application ID you generated out of http://search.msn.com/developer

Tip / Trick on overcoming against proxies

Your sample is ready to run.  However, in case you are behind proxy / firewall, there might be a System.Net Exception error you get at catch.  To solve that, use the following settings in the Web.Config.  You need to place the following settings above <system.web> start tag or after the </system.web> end tag, basically outside the system.web settings.

<system.net>
    <defaultProxy>
      <proxy usesystemdefault="False"
             proxyaddress="Specify Your Proxy Address: Specify Port Number"
bypassonlocal="False"/>
    </defaultProxy>
  </system.net>

Earlier, I had written a detailed article on this topic, as well as how you can specify the above settings programmatically.  Check http://geekswithblogs.net/ranganh/archive/2005/08/29/51474.aspx for the same.

When you now run your Website, you can see that upon entering a search item in the TextBox and clicking on the "Search" button, you get the search results from Live.com bound to your GridView

Resources

To learn more about Live visit http://www.live.com

To learn more about the Developer services visit http://dev.live.com

For more samples on the other APIs, visit http://msdn2.microsoft.com/en-us/library/bb264574.aspx

Cheers!!!

ASP.NET AJAX Developer Virtual Classrooms

Recently, we did a webcast series on ASP.NET AJAX, Silverlight and Windows Live.  If you missed out the same, the Webcasts can be downloaded for offline viewing from http://www.microsoft.com/india/webcasts/ondemand.aspx

Visit the above page and Click on "Next Generation Web Applications" tab in the left and you can find a bunch of our webcasts including the ASP.NET AJAX Webcasts.  If you scroll down a little you can find all my webcasts starting with ASP.NET AJAX - Part I to AJAX Control Toolkit.  Also, you can download useful webcasts on Orcas, Silverlight etc.,

Meanwhile, I am doing a Developer Virtual Classroom series, starting June 4th - June 8th.  Its a 5 day virtual classroom at 2:30pm - 4pm everyday.  Whats different about Virtual Classroom is that, you get to take online evaluation and can be more participative than just listening.  Also, upon completion of evaluations and 80% correctness, you can win certificate of participation from Microsoft.

The series is going to focus on ASP.NET AJAX in detail and it starts with introduction to Ajax, Partial Page Updates etc., and ends with some advance extender example on AJAX Control Toolkit.  So, go ahead and if you havent registered for the Virtual Classrooms, you can register for the same from http://www.microsoft.com/India/virtualclassrooms/

If you are looking for specific area in AJAX, please post the same in the comments so that I can try to include the same during the virtual classroom.

Hoping to see you all there !

Cheers !!

«May»
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789