make your templates as ascx files, use Page.LoadControl method

解决方案 »

  1.   

    用ASCX?具体怎么做呢?给个例子好吗?
    可以实现多模斑选择吗?就是用多个ASCX文件作为模板后,我建立多个ASCX文件,在.aspx中按照某个参数来选择用哪个ASCX作为模板
      

  2.   

    use Page.LoadControl method归思大哥,请详细解释一下这个好吗?谢谢
      

  3.   

    ASCX (user control) is just like an ASPX page, seeWalkthrough: Converting a Web Forms Page to a User Control
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkWalkthroughConvertingWebFormToUserControl.aspsay your ascx is named "my1.ascx","my2.ascx",...,in your aspx page, you could do
    void Page_Load(Object o, EventArgs e)
    {
       Control c = LoadControl("my" + Request.Params["mod"] + ".ascx");
       this.Controls.Add(c); //or Form1.Controls.Add(c);
    }