asp.net ¶ÁÈ¡XmlÎļþ²¢½øÐÐDropDownListÊý¾Ý°ó¶¨
<asp:DropDownList ID="compactType" runat="server" AutoCallBack="True" Width="153px"> </asp:DropDownList>
<?xml version="1.0" encoding="utf-8" ?>
<roots>
<root>
<id>1</id>
<Culture>³õÖÐÒÔÏÂ</Culture>
</root>
<root>
<id>2</id>
<Culture>³õÖÐ</Culture>
</root>
<root>
<id>3</id>
<Culture>ÖÐר</Culture>
</root>
<root>
<id>4</id>
<Culture>¸ßÖÐ</Culture>
</root>
<root>
<id>5</id>
<Culture>´óר</Culture>
</root>
<root>
<id>6</id>
<Culture>±¾¿Æ</Culture>
</root>
</roots>
/// <summary>
/// ¶ÁÈ¡xmlÎļþ,ÓÃÊý¾ÝÌî³äDropDownList,½øÐаó¶¨
/// </summary>
/// <param name="path">xmlÎļþ·¾¶</param>
/// <param name="dp">Òª½øÐа󶨵ÄDropDownListÃû³Æ</param>
/// <param name="id">DropDownListÒªÏÔʾµÄÎı¾(xmlÎļþµÄÒ»¸ö½Úµã)</param>
/// <param name="val">DropDownListÒªÏÔʾµÄÖµ(xmlÎļþµÄÒ»¸ö½Úµã)</param>
public void ReadXml(string path,DropDownList dp,string id,string val)
{
DataSet ds = new DataSet();
ds.ReadXml(path);
dp.DataSource = ds;
dp.DataTextField = id ;
dp.DataValueField = val;
dp.DataBind();
}
SecurityFactory sf = new SecurityFactory();
//xmlÎļþ·¾¶
string path2 = Server.MapPath("./xml/XMLFile2.xml");
sf.ReadXml(path2, this.compactType, "id", "val");
Ïà¹ØÎĵµ£º
1.route.xmlÎļþÄÚÈÝ
<?xml version="1.0" encoding="GBK"?>
<root>
<route id="1111">
<id>111</id>
<name>ËÄ´¨</name>
<path>www.baidu.com/hehe.html</path>
</route>
</root>
2.test.html´úÂë
<html>
<body>
<script> ......
[System.Runtime.Serialization.DataMemberAttribute()]
public Information Archive {
get {
&n ......
<asp:TemplateField HeaderText="²âÊÔ">
<ItemTemplate>
<asp:LinkButton ID="test" runat="server" OnClick="test_Click" OnClientClick='<%# string.Format("return confirmDelete(\"{0} {1}\");", DoEscape((string)Eval( ......
ÓÃAsp.NetÉÏ´«Îļþ,Ê×Óõ½µÄÊÇFileUpload¿Ø¼þ
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:Button ID="btn" runat="server" Text="È·¶¨" OnClick="btn_Click"/>
C#´úÂë
protected void btn_Click(object sender, EventArgs e)
{
//ÅÐ¶Ï ......
dzÎöASP.NETµÄPage.IsPostBack ÊôÐÔ
http://www.sina.com.cn 2008Äê05ÔÂ06ÈÕ 11:33 IT168.com
¡¾IT168¼¼ÊõÎĵµ¡¿
ÏÖÔÚ´Ó¶ÔASP.NETÒ³ÃæµÄÖ´ÐÐ˳Ðò¿ªÊ¼£¬Ìå»áÒ»ÏÂB/S½á¹¹µÄ³ÌÐòµÄÌØµã£¬ÏÂͼÊÇASP.NETÒ³ÃæµÄÖ´ÐÐ˳Ðò˵Ã÷£º
Page_Init£¨Ò³Ãæ³õʼ»¯Òý·¢µÄʼþ£©——>Page_Load£¨¼ÓÔ ......