<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestUcEmployee.aspx.cs" Inherits="TestUcEmployee" %> |
|
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!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 id="Head1" runat="server"> |
<title>Untitled Page</title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<asp:ScriptManager ID="ScriptManager1" runat = "server"></asp:ScriptManager> |
|
<br /> |
<br /> |
|
<table> |
<tr> |
|
<td style="width:100px"> </td> |
<td align="right" id="tdDocks" runat="server" style="width:1000px"> |
</td> |
|
</tr> |
</table> |
</div> |
</form> |
</body> |
</html> |
|
|
------------------------------------ |
|
using System; |
using System.Data; |
using System.Configuration; |
using System.Collections; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Web.UI.HtmlControls; |
using Telerik.Web.UI; |
using System.Reflection; |
|
using System.Configuration; |
using System.Collections.Generic; |
|
public partial class TestUcEmployee : System.Web.UI.Page |
{ |
|
protected void Page_Load(object sender, EventArgs e) |
{ |
|
RadDockLayout layout1 = new RadDockLayout(); |
RadDockZone zone1 = new RadDockZone(); |
for (int i = 1; i < 12; i++) |
{ |
|
|
|
zone1.Width = Unit.Pixel(900); |
zone1.Orientation = Orientation.Horizontal; |
if (i % 2 == 0) |
{ |
zone1.BackColor = System.Drawing.Color.PeachPuff; |
} |
else |
{ |
zone1.BackColor = System.Drawing.Color.AliceBlue; |
} |
|
|
RadBinaryImage image = new RadBinaryImage(); |
image.ResizeMode = BinaryImageResizeMode.Fit; |
image.Height = Unit.Pixel(100); |
image.Width = Unit.Pixel(70); |
|
LiteralControl liSpace = new LiteralControl(" "); |
LiteralControl liTitle = new LiteralControl("Title"); |
|
|
Table table = new Table(); |
table.BorderWidth = Unit.Pixel(0); |
table.Width = Unit.Percentage(85); |
TableRow tr1 = new TableRow(); |
TableRow tr2 = new TableRow(); |
|
tr1.HorizontalAlign = HorizontalAlign.Center; |
tr2.HorizontalAlign = HorizontalAlign.Center; |
|
TableCell tc1 = new TableCell(); |
tc1.Controls.Add(liSpace); |
TableCell tc2 = new TableCell(); |
/* |
if (!dt.Rows[i]["Photo"].Equals(System.DBNull.Value)) |
{ |
image.DataValue = (byte[])dt.Rows[i]["Photo"]; |
} |
tc2.Controls.Add(image); |
*/ |
Control widget = LoadControl("UCEmployee.ascx", i); |
tc2.Controls.Add(widget); |
|
TableCell tc3 = new TableCell(); |
tc3.Controls.Add(liSpace); |
|
tr1.Cells.Add(tc1); |
tr1.Cells.Add(tc2); |
tr1.Cells.Add(tc3); |
|
TableCell tc4 = new TableCell(); |
tc4.Controls.Add(liSpace); |
TableCell tc5 = new TableCell(); |
tc5.Controls.Add(liSpace); |
TableCell tc6 = new TableCell(); |
tc6.Controls.Add(liSpace); |
|
tr2.Cells.Add(tc4); |
tr2.Cells.Add(tc5); |
tr2.Cells.Add(tc6); |
|
table.Controls.Add(tr1); |
table.Controls.Add(tr2); |
|
|
|
RadDock dock = new RadDock(); |
dock.UniqueName = Guid.NewGuid().ToString(); |
dock.ID = string.Format("RadDock{0}", dock.UniqueName); |
dock.Title = "Title";//dt.Rows[i]["FirstName"].ToString() + " " + dt.Rows[i]["LastName"].ToString(); |
dock.TitlebarContainer.HorizontalAlign = HorizontalAlign.Center; |
|
dock.ContentContainer.Controls.Add(table); |
|
|
RadDock dockSpace = new RadDock(); |
dockSpace.UniqueName = Guid.NewGuid().ToString(); |
dockSpace.ID = string.Format("RadDock{0}", dock.UniqueName); |
dockSpace.Style["Width"] = "900px"; |
|
if (i % 3 == 0) |
{ |
dock.Style["Width"] = "300px"; |
|
zone1.Controls.Add(dock); |
|
dockSpace.ContentContainer.Controls.Add(new LiteralControl("<table width='100%' height='10px' border='0'><tr><td> </td> <td> </td> <td></td></tr></table>")); |
zone1.Controls.Add(dockSpace); |
} |
else |
{ |
dock.Style["Width"] = "300px"; |
|
zone1.Controls.Add(dock); |
} |
|
} |
layout1.Controls.Add(zone1); |
tdDocks.Controls.Add(layout1); |
} |
|
|
private UserControl LoadControl(string UserControlPath, params object[] constructorParameters) |
{ |
List<Type> constParamTypes = new List<Type>(); |
foreach (object constParam in constructorParameters) |
{ |
constParamTypes.Add(constParam.GetType()); |
} |
|
UserControl ctl = Page.LoadControl(UserControlPath) as UserControl; |
|
// Find the relevant constructor |
ConstructorInfo constructor = ctl.GetType().BaseType.GetConstructor(constParamTypes.ToArray()); |
|
//And then call the relevant constructor |
if (constructor == null) |
{ |
throw new MemberAccessException("The requested constructor was not found on : " + ctl.GetType().BaseType.ToString()); |
} |
else |
{ |
constructor.Invoke(ctl, constructorParameters); |
} |
|
// Finally return the fully initialized UC |
return ctl; |
} |
|
} |
|