dynamisk loadning og indsætning af usercontrols
Hej eksperter,Jeg har en masterpage på hvilken jeg dynamisk prøver at load en usercontrol ind i en placeholder på. Men controlen bliver ikke loadet men der kommer ikke nogle fejl ???
min master mage ser sådan her ud :
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Template.master.cs" Inherits="Tholder" %>
<%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<%@ Reference Control="~/GlobalControls/Chart1.ascx" %>
<%@ Reference Control="~/GlobalControls/Chart2.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="TContent" runat="server">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
og dens code behind ser sådan her ud :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class Tholder : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request.QueryString["Id"].ToString() == "1"){
Control TheControls = LoadControl("~/GlobalControls/Chart1.ascx");
ContentPlaceHolder2.Controls.Add(TheControls);
}else{
Control TheControls = LoadControl("~/GlobalControls/Chart2.ascx");
ContentPlaceHolder2.Controls.Add(TheControls);
}
}
}
er der nogle der kan se hvor problemet er !!!