Đăng ký vps giá rẻ, tên miềndomain. Việc kiểm tra và mua tên miền giá rẻ, domain giá rẻ, hosting giá rẻ, máy chủ ảo giá rẻserver giá rẻ chỉ với 2 bước đơn giản. Giúp bạn tiên phong trong kinh doanh Online

Asp.net
 9ecva.com - 9e Chu Van An Forever : Asp.net
Tiêu đề Chủ đề: Lấy thông tin thời tiết, tỷ giá Trả lời bài viếtGửi bài viết mới
Tác giả
Nội dung << Chủ đề trước | Chủ đề kế tiếp >>
DUCVINH83
Administrator
Administrator
Avatar
Không ngừng học hỏi !

Ngày gia nhập: 01/11/2005
Giới tính:
Đến từ: Vietnam
Trạng thái:
Bài viết: 365
Tiền: 738$
Địa chỉ e-mail: Gửi mail
Yahoo! IM: Yahoo! IM
Sinh nhật: 17/02/1983
Cảnh cáo: (0%)
Minus 1 warningCurrent warnlevel: 0%Add 1 warning
Ngày gửi: 16/08/2011 lúc 10:57 sáng | Đã khóa IP Trích dẫn DUCVINH83

Lấy thông tin thời tiết (Giống như hmweb)


Các thông tin thời tiết của vnexpress.net được lưu dưới dạng file.xml tại http://vnexpress.net/ListFile/Weather/ (Với Hà Nội là hanoi.xml, …). Vậy cách thực hiện của mình là đọc nội dung từ file xml bind ra datatable, mà file xml được lấy bằng đường dẫn tuyệt đối như  http://vnexpress.net/ListFile/Weather/hanoi.xml (Bạn nên viết thành control để sử dụng). Trong trang aspx bạn cần như sau:

<asp:Label ID=”Label1″ runat=”server” Font -Bold=”True” Font-Size=”11pt” Text=”Thông tin thời tiết”></asp:Label><br />

<asp:DropDownList ID=”DropDownList1″ runat=”ser ver” AutoPostBack=”True”OnSelectedIndexChanged=”DropDow nList1_SelectedIndexChanged” Font-Names=”Tahoma” F ont-Size=”11px” Width=”112px”>

<asp:ListItem Selected=”True” Value=”Hanoi.xml” >Hà Nội</asp:ListItem>

<asp:ListItem Value=”Haiphong.xml”>Hải Phòng</asp:ListItem>

<asp:ListItem Value=”HCM.xml”>TP HCM</asp:ListItem>

<asp:ListItem Value=”Danang.xml”>Đà Nẵng< /asp:ListItem>

<asp:ListItem Value=”Sonla.xml”>Sơn La</asp:ListItem>

<asp:ListItem Value=”Viettri.xml”>Việt Trì</asp:ListItem>

<asp:ListItem Value=”Vinh.xml”>Vinh</asp:ListI tem>

<asp:ListItem Value=”Nhatrang.xml”>Nha Trang</asp:ListItem>

<asp:ListItem Value=”Pleicu.xml”>Pleicu</asp:L istItem>

</asp:DropDownList></div>

<asp:Literal ID=”Literal1″ runat=”server”>&l t;/asp:Literal>

Trong code bạn viết như sau:
protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

try

{

LoadData(“http://vnexpress.net/ListFile/Weather/hanoi.xml”);

}

catch { }

}

}

// Hàm bind dữ liệu xml ra DataTable

private DataTable GetTable(string FileName)

{

DataTable dtb = new DataTable();

DataSet authorsDataSet;

string filePath = FileName;

authorsDataSet = new DataSet();

authorsDataSet.ReadXml(filePath);

dtb = authorsDataSet.Tables[0];

return dtb;

//GridView1.DataSource = authorsDataSet.Tables[0].DefaultView;

//GridView1.DataBind();

}

// Load dữ liệu theo filepath

private void LoadData(string xmlFilePath)

{

DataTable dtb = GetTable(xmlFilePath);

if (dtb.Rows.Count > 0)

{

Literal1.Text = “&nbsp;<img src=’http://vnexpress.net/Images/Weather/” + dtb.Rows[0][0].ToString().Trim() + “‘>”;

Literal1.Text += “<img src=’http://vnexpress.net/Images/Weather/” + dtb.Rows[0][1].ToString().Trim() + “‘>”;

Literal1.Text += “<img src=’http://vnexpress.net/Images/Weather/” + dtb.Rows[0][2].ToString().Trim() + “‘>”;

Literal1.Text += “<img src=’http://vnexpress.net/Images/Weather/c.gif’>”;

Literal1.Text += “<br>” + dtb.Rows[0][6].ToString().Trim();

}

dtb.Dispose();

}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{

LoadData(“http://vnexpress.net/ListFile/Weather/” + DropDownList1.SelectedValue.ToString());

}

Bảng giá chứng khoán trực tuyến


Để lấy thông tin chứng khoán trực tuyến bạn ghép đoạn code sau vào nơi muốn hiển thị, Bạn có thể điều chỉnh chiệu rộng và cao cho hợp lý
<script language="javascript">
 function switchActive(i){
    if(i == 0){
        document.getElementById('cHoSTC').className = 'cActive';
        document.getElementById('cHaSTC').className = 'cNoActive';
        document.getElementById('aHoSTC').className = 'Active';
        document.getElementById('aHaSTC').className = 'NoActive';
    }
    else{
        document.getElementById('cHoSTC').className = 'cNoActive';
        document.getElementById('cHaSTC').className = 'cActive';
        document.getElementById('aHoSTC').className = 'NoActive';
        document.getElementById('aHaSTC').className = 'Active';
    }
}
</script>

Trong đó bạn cần viết các css class cActive, cNoActive … để trình bày cho phụ hợp

<table align=”center” border=”0″ cellpaddi ng=”0″ cellspacing=”0″ width=”180px”>

<tr>

<td align=”left” height=”5″>

</td>

</tr>

<tr>

<td align=”center” class=”headerTitleBanner”&nb sp;height=”22″>

<b>Bảng giá CK trực tuyến</b></td>

</tr>

<tr>

<td align=”left”>

<table  border=”0″ cellpadding=”0″ ce llspacing=”1″ style=”width: 100%”>

<tr>

<td align=”center” colspan=”5″ rowspan=”1″  >

<table style=”border-collapse: collapse;” border=”0″ cellpadding=”0″ cellspa cing=”0″ width=”100%”>

<tr>

<td id=”cHoSTC” class=”cActive”  heig ht=”20″ align=”center”>

<a href=”http://vnexpress.net/User/ck/hcms/HCMStockS mall.asp” target=”ifrmChungKhoan” id=”aHoSTC”class =”Active” onClick=”switchActive(0);” onMouseOver=” window.status=’Chung khoan TP HCM’;  return true;”onMouseOut=”window.status=”;  return true;”>HoSTC</a>

</td>

<td id=”cHaSTC” class=”cNoActive”  he ight=”20″ align=”center”>

<a href=”http://vnexpress.net/User/ck/hns/HNStockSma ll.asp” target=”ifrmChungKhoan” id=”aHaSTC”class=” NoActive” onClick=”switchActive(1);”onmouseover=”window .status=’Chung khoan TP Ha Noi’;  return true;”onMouseOut=”window.status=”;  return true;”>HaSTC</a>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td align=”center” style=”width: 20%; “ class=”TDbanner” rowspan=”2″>

CK</td>

<td align=”center” style=”width: 20%;” class=”TDbanner” rowspan=”2″>

TC</td>

<td align=”center”  class=”TDtitle” c olspan=”2″>

Khớp lệnh</td>

<td align=”center” style=”width: 20%; “ class=”TDbanner” rowspan=”2″>

+/-</td>

</tr>

<tr>

<td align=”center” class=”TDbanner” style= ”width: 20%;”>

Giá</td>

<td align=”center” class=”TDbanner” style= ”width: 20%;”>

KL</td>

</tr>

</table>

<table width=”100%” border=”0″ cellspacing =”0″ cellpadding=”0″>

<tr>

<td align=”center” colspan=”5″>

</td>

</tr>

 

</table>

</td>

</tr>

</table>



__________________

YM: DUCVINH83
0912 822334


Lên trên Xem DUCVINH83's Thông tin cá nhân Tìm những bài viết khác của DUCVINH83 Ghé thăm DUCVINH83's Trang chủ
 

Nếu bạn muốn trả lời thì trước tiên bạn phải đăng nhập
Nếu chưa đăng ký thì bạn hãy đăng ký

  Trả lời bài viếtGửi bài viết mới
Xem trang in Xem trang in

Di chuyển nhanh
Bạn không thể tạo đề tài mới
Bạn không thể trả lời bài viết
Bạn không thể xoá bài viết bạn đã gưi
Bạn không thể sửa bài viết bạn đã gửi
Bạn không thể tạo bình chọn
Bạn không thể bình chọn



Trang này được tạo ra trong 0.2109 giây.
cheap jordans for salecheap jordans for salecheap jordans for salecheap jordans for salecheap jordans for salecheap jordans for salecheap jordans for salecheap jordans for salecheap jordans for salesac longchamp pas chergucci outlet

baomang.net  9ecva.com © 2007 - Phát triển bởi Trịnh Đức Vinh