Tuesday, August 31, 2010

Fill Dropdown Chain Using Ajax

This is how you can fill dropdown list from another dropdown's change event in Asp.net/ C# using Ajax.

First,

Create one web application in ASP.Net/C#.

In default.aspx paste below coding.



<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="myScripManager" EnablePartialRendering="true" runat="server"></asp:ScriptManager>
    
    <script language="javascript" type="text/javascript"> 
           var prm = Sys.WebForms.PageRequestManager.getInstance(); 
           prm.add_initializeRequest(InitializeRequest); 
           prm.add_endRequest(EndRequest); 
           function InitializeRequest(sender,args) 
           { 
              $get('chainUpdate').style.display = 'block'; 
           } 
           function EndRequest(sender,args) 
           { 
              $get('chainUpdate').style.display = 'none'; 
           } 
    </script>
    
    <div>
        <asp:UpdatePanel ID="chainPanel" ChildrenAsTriggers="true" RenderMode="Block" UpdateMode="Conditional" runat="server">
            <ContentTemplate>
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td>
       <font style="font-size:11px;font-family:verdana;">Search for:</font>
       </td>
   <td style="padding-left:10px;">
       <asp:DropDownList ID="drpMain" AutoPostBack="true" OnSelectedIndexChanged="drpMain_SelectedIndexChanged" runat="server">
       <asp:ListItem Text="(Select)" Value="0" Selected="True"></asp:ListItem>
   <asp:ListItem Text="Gujarat" Value="1"></asp:ListItem>
   <asp:ListItem Text="Maharastra" Value="2"></asp:ListItem>
                            <asp:ListItem Value="3">Rajasthan</asp:ListItem>
   </asp:DropDownList>
   </td>
   <td style="padding-left:10px;">
       <asp:DropDownList ID="drpMoto" Width="220px" AutoPostBack="true" OnSelectedIndexChanged="drpMoto_SelectedIndexChanged" Enabled="false" runat="server"/>
       </td>
   <td style="padding-left:10px;">
                        &nbsp;</td>
   <td style="padding-left:10px;">
       <asp:Button ID="btnGo" Text="Go" OnClick="btnGo_OnClick" Enabled="false" runat="server" />
   </td>
                </tr>
                <tr>
                    <td colspan="5" style="text-align:left;">
                        <asp:UpdateProgress ID="chainUpdate"  AssociatedUpdatePanelID="chainPanel" runat="server">
                            <ProgressTemplate>
                                <img src="img/updating.gif" alt="Updating..." style="font:12px verdana;vertical-align:middle;" />
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <br /><br />
                        <asp:Label ID="lblResult" runat="server"></asp:Label>
                    </td>
                </tr>
            </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>



In code behind write below code

using System;
using System.Data;
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page 
{
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Cache["Motos"] == null)
        {
            ds.ReadXml(Server.MapPath("~/XMLFiles/Motors.xml"), XmlReadMode.InferSchema);
            Cache.Insert("Motos", ds);
        }
        else
            ds = (DataSet)Cache["Motos"];
    }

    protected void drpMain_SelectedIndexChanged(object sender, EventArgs e)
    {

        DataSet ds1 = new DataSet();
        string provider = "Provider=Microsoft.Jet.OLEDB.4.0;";
        string db = "Data Source=D:\\Northwind.mdb";
        string connstr = provider + db;
       
        //System.Threading.Thread.Sleep(1200);

        drpMoto.Items.Clear();
            string query = "SELECT * FROM city WHERE stateid =" + drpMain.SelectedValue;
            OleDbConnection conn = new OleDbConnection(connstr);
            //conn.Open();
            OleDbDataAdapter ad = new OleDbDataAdapter(query, conn);
            ad.Fill(ds1, "city");
           
            drpMoto.DataTextField = "cityname";
            drpMoto.DataValueField = "cityid";
            drpMoto.DataSource = ds1.Tables["city"];
            drpMoto.DataBind();
            //conn.Close();
            //ds1.Dispose();
            //conn.Dispose();
            drpMoto.Enabled = true;
//            drpBrand.Items.Clear();
//            drpBrand.Enabled = false;
            btnGo.Enabled = false;
            
        
    }

Thursday, August 26, 2010

Google to allow phone calls from Gmail

A construction worker walks past a logo next to the main entrance of the Google...
...
Google Inc said users of Gmail will now be able to call telephones directly from their email, putting it in direct competition with Web calling service Skype and more traditional operators such as AT&T Inc and Verizon Communications.
While Google had already offered computer-to-computer voice and video chat services, it said that starting on Wednesday it will now allow calls to home phones and mobile phones directly from Gmail for the first time.
Google promised free calls to U.S. and Canadian phones from Gmail for the rest of this year and said it would charge low rates for calls made to other countries.
For example it said calls to Britain, France, Germany, China and Japan would be as low as 2 cents per minute.
Analysts said the service would likely be a bigger competitive threat to services like Skype's than to traditional phone companies, which have already been cutting their call prices in recent years in response to stiff competition.
"This is a risk to Skype. It's a competitor with a pretty good brand name," said Hudson Square analyst Todd Rethemeier.
Skype, which owned by private equity firms and eBay Inc and planning a $100 million initial public offering, has long allowed consumers to make calls from computers to phones. Skype became popular by first offering free computer-to-computer voice and video services.
Like Skype, Rethemeier said the Google service will likely be much more popular among U.S. consumers making international calls, than among people calling friends inside the country.
"Calling is so cheap already that I don't think it will attract a huge amount of domestic calling. It could take some of the international market," he said.
Another analyst, Steve Clement from Pacific Crest, said that anybody who is tempted by Internet calling services has likely already disconnected their home phone.
"The type of person who would use a service like that isn't the type of customer who still has a landline," Clement said.
Google said making a call through its service works like a normal phone in that a user could click on the "call phone" option in their chat buddy list in Gmail and type in the number or enter a contact's name.
Calls that cost money will be charged from an online account that users can top up with a credit card, Google said. The service will not be available for making outgoing calls on cell phones because other Google apps already cater to that market, the company added.

Facebook Surpasses Orkut in India Says comScore

Finally, popular social networking site Facebook has taken the top position and surpassed Google's Orkut website this year. According to market research company comScore's latest report, it is clear that Facebook has won the number one rank with 20.9 million visitors in July in India. This figure has risen by 179 percent on a year-on-year basis. On the other hand, Orkut has managed to grow by a mere 16 percent.

For years, Orkut has been ruling million of hearts in India - Yeah, it's that dramatic. However, in past one year, the entire social networking traction has evolved and moved towards fiercely popular Facebook. The major reasons are the different interface and most importantly, the presence of social gaming apps like FarmVille, FishVille, Mafia Wars, Sudoku and many more. No wonder FarmVille makers have set their foot in the rapidly growing online audience of India. Orkut, on the other hand, has tried every possible thing to retain users with the new interface and also support for Apps.

Overall, the Internet traffic visiting social networking sites grew 43 percent year-on-year. Also, popular micro-blogging website Twitter has seen a phenomenal 233 percent growth. However, MySpace-like website Shtyle.fm has recording highest percentage change (281 percent).

India is now the seventh largest social networking market worldwide after U.S., China, Germany, Russian Federation, Brazil and the UK.

Also, in recent times, we've noticed a lot of Indian websites integrate Facebook and Twitter features to popularize themselves.