| 网站首页 | 硬件维修 | 应用学院 | 网络组建 | 网站制作 | 菜鸟黑客 | 编程之道 | 数码大全 | 娱乐休闲 | 软件下载 | 在线视频 | 请您留言 | 技术论坛 | 
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
  • javascript制作闪烁的边…

  • javascript制作浮动的工…

  • js控制excel打印完美解决方案

  • 在网页中控制wmplayer播放器

  • 一个简单的javascript菜…

  • 一个很通用的javascript…

  • javascript学习:基础继承…

  • 制作仿“QQ秀”的虚拟形象

  • 连续滚动的制作

  • 图片控制的渐变色文字

  • Q
    您现在的位置: 我是IT人 >> 网站制作 >> ASP >> 文章正文
    制作一个简单的服务器端控制         
    制作一个简单的服务器端控制
    作者:网络 文章来源:转载 点击数: 更新时间:2005-9-30
    [ 字体:缩小 正常 放大 | 双击自动滚屏 ]
    请选择合适的字体颜色:


    2000082805.aspx
    -------------------------------------------------------------
    <%@ Register TagPrefix="CJ" Namespace="cjServerControls" %>
    <html>
    <head>
    </head>
    <body>

    <form method="post" action="2000082605.aspx" runat="server">
    <CJ:xmlDocReader listText="au_id" listValue="au_id" runat="server"
    path="C:\Inetpub\wwwroot\myASP\tutorials\authors.xml" />
    </form>

    </body>
    </html>

    2000082805a.cs
    -------------------------------------------------------------
    using System;
    using System.Data;
    using System.IO;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace cjServerControls
    {
    public class xmlDocReader : Control, INamingContainer
    {
    string _xmlPath;
    string _listID;
    string _listValue;

    public string Path
    {
    get { return _xmlPath; }
    set { _xmlPath = value; }
    }

    public string listText
    {
    get { return _listID; }
    set { _listID = value; }
    }

    public string listValue
    {
    get {return _listValue; }
    set {_listValue = value; }
    }

    //Were are creating a member here so we can access it throughout the class
    DropDownList _DDL;
    DataGrid _DG;
    FileStream fs;
    StreamReader sr;
    DataSet ds;
    protected override void PreRender()
    {
    if (Page.IsPostBack) {
    DataView dv = new DataView(ds.Tables[0]);
    dv.RowFilter = listValue + "='" + _DDL.SelectedItem.Text + "'";
    _DG = new DataGrid();
    _DG.DataSource = dv;
    _DG.DataBind();
    Controls.Add(_DG);
    }
    }

    protected override void CreateChildControls()
    {
    fs = new FileStream(Path, FileMode.Open, FileAccess.Read);
    sr = new StreamReader(fs);
    ds = new DataSet();
    ds.ReadXml(sr);
    fs.Close();

    [1] [2] [3] [4] [5] [6] 下一页  

    文章录入:小秦    责任编辑:小秦 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 关于我们 | 友情链接 | 版权申明 |