Ajax etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Ajax etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

24 Ekim 2013 Perşembe

Sharepoint Weather Condition Webpart Update By Using UpdatePanel


Html Code

<div class="havadurumu">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <img id="imgsrc" runat="server" width="60" /><span class="havadurumub"><asp:Literal ID="ltrderece" runat="server"></asp:Literal>
                °C</span>
            <br />
            <asp:DropDownList ID="drplist" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drplist_SelectedIndexChanged">
                <asp:ListItem Value="2344116" Text="İstanbul"></asp:ListItem>
                <asp:ListItem Value="2343732" Text="Ankara"></asp:ListItem>
                <asp:ListItem Value="2343733" Text="Antalya"></asp:ListItem>
                <asp:ListItem Value="2343859" Text="Çanakkale"></asp:ListItem>
                <asp:ListItem Value="2343977" Text="Erzurum"></asp:ListItem>
                <asp:ListItem Value="2344117" Text="İzmir"></asp:ListItem>
            </asp:DropDownList>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="drplist" EventName="SelectedIndexChanged"/>
        </Triggers>
    </asp:UpdatePanel>
 
</div>
---------------------------------------------------------------------------------------------

ASP.NET Code

  protected void Page_Load(object sender, EventArgs e)
        {
            raporcek();
        }

        protected void drplist_SelectedIndexChanged(object sender, EventArgs e)
        {
            raporcek();

        }

        private void raporcek()
        {
            try
            {
                string deger = drplist.SelectedValue.ToString();
                XmlTextReader txt = new XmlTextReader("http://weather.yahooapis.com/forecastrss?w=" + deger + "&u=c");
                while (txt.Read())
                {
                    if (txt.Name == "yweather:condition")
                    {
                        string a = txt.GetAttribute("temp");
                        ltrderece.Text = a;

                    }

                }
                string RSS = "http://weather.yahooapis.com/forecastrss?w=" + deger + "&u=c";
                //Change w value to get your location ...

                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(RSS);

                XmlNodeList ItemList = xDoc.GetElementsByTagName("item");
                string Title = ItemList[0].SelectSingleNode("title").InnerText;
                string Description = ItemList[0].SelectSingleNode("description").InnerText;
                string[] resim = Description.Split('"');
                imgsrc.Src = resim[1].ToString();
            }
            catch
            {

            }
        }


So our page not postback,only "update panel" division change...