Hello.
Please, i need a help.
I am adding TreeView dynamically not directly to form.Controls collection but to another my nested control.
Is it possible?
I am getting javascript error in _preInitialize method...
Thank you very much.
Please, i need a help.
I am adding TreeView dynamically not directly to form.Controls collection but to another my nested control.
Is it possible?
I am getting javascript error in _preInitialize method...
Thank you very much.
using System; | |
using System.Data; | |
using System.Configuration; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Security; | |
using System.Web.UI; | |
using System.Web.UI.HtmlControls; | |
using System.Web.UI.WebControls; | |
using System.Web.UI.WebControls.WebParts; | |
using System.Xml.Linq; | |
using System.Xml; | |
using Telerik.Web.UI; | |
using System.Collections.Generic; | |
namespace CB.LayerPresentation.Controls.Input | |
{ | |
public class FluTelTreeview : FluTelBase | |
{ | |
protected DataTable dtData; | |
protected RadTreeView treeView; | |
public FluTelTreeview(ScriptManager sm, XmlDocument xdProperties): base(sm,xdProperties) | |
{ | |
this.treeView = new RadTreeView(); | |
this.treeView.Skin = "Office2007"; | |
this.Controls.Add(this.treeView); | |
// all control properties are set up during this method with help of reflection | |
if (this.xdProperties != null) | |
{ | |
this.SetupProperties(this.treeView, null, xdProperties.DocumentElement); | |
this.SetupProperties(this, "OuterControl", xdProperties.DocumentElement); | |
} | |
} | |
public void SetData(DataTable dtData) | |
{ | |
this.dtData = dtData; | |
this.treeView.DataSource = dtData; | |
this.treeView.DataBind(); | |
} | |
protected override void OnPreRender(EventArgs e) | |
{ | |
if (this.sm != null) | |
{ | |
if (!this.DesignMode) | |
sm.RegisterScriptControl(this); | |
} | |
base.OnPreRender(e); | |
} | |
protected override void Render(HtmlTextWriter writer) | |
{ | |
//base.Render(writer); | |
this.SetInputNameAndControlID(); | |
if (this.isUpdateRestricted) | |
{ | |
writer.WriteLine("<span id=" + this.inputName + "LikeInput>" + this.Value + "</span>"); | |
} | |
else | |
{ | |
if (!this.DesignMode) | |
sm.RegisterScriptDescriptors(this); | |
this.treeView.ID = this.ID + "TreeView"; | |
// nastavení hodnoty | |
// začátek div | |
writer.Write("<div id=" + this.ID + " "); | |
//vnitřní control | |
writer.WriteAttribute("innerControlId", this.treeView.ClientID); | |
if (this.IsValueDefault) | |
writer.WriteAttribute("defVal", this.Value); | |
if (fr.Mandatory) | |
writer.WriteAttribute("mandatory", fr.Mandatory.ToString()); | |
writer.WriteAttribute("isUpdateRestricted", (this.isUpdateRestricted ? "1" : "0")); | |
writer.WriteLine(" >"); | |
// tree view is rendered | |
this.RenderChildren(writer); | |
//konec div | |
writer.WriteLine("</div>"); | |
} | |
//hidden with current value | |
this.RenderHiddenValue(writer,""); | |
// hidden with old value | |
if (!this.isUpdateRestricted) | |
this.RenderOldValueHidden(writer); | |
} | |
protected override IEnumerable<ScriptReference> GetScriptReferences() | |
{ | |
ScriptReference reference = new ScriptReference(); | |
reference.Path = ResolveClientUrl("scripts/FluTelTreeView.js"); | |
return new ScriptReference[] { reference }; | |
} | |
protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors() | |
{ | |
ScriptControlDescriptor descriptor = new ScriptControlDescriptor("FluTel.TreeView", this.ID); | |
return new ScriptDescriptor[] { descriptor }; | |
} | |
} | |
} | |