12-6-2011 15:38:33
fro nao giai thick cho e doan code nay voi em doc ma e chang hieu cai j ca!mong duoc cac fro giup do em cam on nhieu

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using System.Net;
using System.Text;
namespace SK.Weather
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The Weather_KTTVTW class displays the content
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// </history>
/// -----------------------------------------------------------------------------
partial class Weather_KTTVTW : PortalModuleBase
{
#region Private Methods
/// <summary>
/// Gets the weather info.
/// </summary>
/// <returns></returns>
public string GetWeatherInfo()
{
try
{
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
string content = client.DownloadString("http://www.nchmf.gov.vn/web/vi-VN/43/Default.aspx");
string strBegin = @"<!-- Begin Display content -->";
string strEnd = "<TD class=\"thoitiet_rightbox_ver\"></TD>";
content = content.Substring(content.IndexOf(strBegin) + strBegin.Length, content.IndexOf(strEnd) - content.IndexOf(strBegin) - strBegin.Length);
content = content.Replace("class", " ");
return content;
}
catch (Exception ex)
{
return "Loading....";
}
}
#endregion
#region Event Handlers
/// -----------------------------------------------------------------------------
/// <summary>
/// Page_Load runs when the control is loaded
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// </history>
/// -----------------------------------------------------------------------------
protected void Page_Load(System.Object sender, System.EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
this.lblContent.CssClass = "text-weather";
this.lblContent.Text = this.GetWeatherInfo();
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
}
}