FLASH连接数据库
System.useCodepage = true;
_global.arrTitle = new Array(5);
_global.arrImage = new Array(5);
_global.arrUrl = new Array(5);
function loadxml()
{
myxml = new XML();
myxml.ignoreWhite = true;
myxml.load("http://192.168.0.244/8mchina2/flash/tvindex.aspx");
myxml.onLoad = function(success)
{
if (success)
{
len = myxml.firstChild.childNodes.length;
for(i=0; i<5; i++)
{
_global.arrTitle[i] = myxml.firstChild.childNodes[i].attributes.title;
_global.arrImage[i] = myxml.firstChild.childNodes[i].attributes.image;
_global.arrUrl[i] = myxml.firstChild.childNodes[i].attributes.url;
eval("_root.txt" + (i+1)).text = _global.arrTitle[i];
}
}
else
{
loadxml();
}
};
}
loadxml();
aspx文件处理:
<%@ Import Namespace="Bmhd.Components.Components" %>
<%@ Import Namespace="Bmhd.Components" %>
<%@ Page language="c#" Codebehind="TVIndex.aspx.cs" AutoEventWireup="false" Inherits="Bmhd.Web.xml.TVIndex" %><?xml version="1.0" encoding="gb2312" ?>
<xml>
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<item id="<%# DataBinder.Eval(Container.DataItem, "ID")%>" title="<%# DataBinder.Eval(Container.DataItem, "Title")%>" url="<%# DataBinder.Eval(Container.DataItem, "Link")%>" image="<%# TopicPicture.GetPictureUrl(DataBinder.Eval(Container.DataItem, "ImageUrl").ToString())%>" />
</ItemTemplate>
</asp:Repeater>
</xml>
后台代码:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//
Response.ContentType = "Text/XML";
Repeater1.DataSource = Topics.GetTop5TVIndex().Topics;
Repeater1.DataBind();
}
参考答案:很好值得学习,不错,不错..