0
這是我的代碼,我創建了我的custum radiobuttonlist。它的作品,但..看看代碼人。即時通訊使用一把umbraco和C#自定義網頁控制html渲染
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.member;
using System.Web.Security;
using umbraco.cms.businesslogic.web;
using System.Collections;
namespace RadioButtonList
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:RadioButtonList runat=server></{0}:RadioButtonList>")]
public class RadioButtonList : System.Web.UI.WebControls.RadioButtonList
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
private void populate()
{
foreach (umbraco.cms.businesslogic.Dictionary.DictionaryItem d in umbraco.cms.businesslogic.Dictionary.getTopMostItems)
{
if (d.hasChildren)
{
foreach (umbraco.cms.businesslogic.Dictionary.DictionaryItem d1 in d.Children)
{
if (d1.hasChildren)
{
if (d1.Value(1) == "Target Groups")
{
SortedList list = new SortedList();
foreach (umbraco.cms.businesslogic.Dictionary.DictionaryItem d2 in d1.Children)
{
string translation;
int lang = umbraco.library.GetCurrentDomains(umbraco.presentation.nodeFactory.Node.GetCurrent().Id)[0].Language.id;
translation = "";
translation = new umbraco.cms.businesslogic.Dictionary.DictionaryItem(d2.key).Value(lang);
list.Add(translation, d2.key);
}
this.DataSource = list;
this.DataValueField = "value";
this.DataTextField = "key";
this.DataBind();
}
}
}
}
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
populate();
}
}
它的工作,我可以得到新的網絡控制,但我想「控制」渲染HTML。我的RadioButtonList呈現一個跨度,但我不想它導致它創建一些問題。我已經嘗試過了這個
protected override void Render(HtmlTextWriter writer)
{
RenderContents(writer);
}
但是,當我使用這個我的radiobuttonlist消失,我不能再看到它了。我真的需要幫助,因爲我是第一次使用custum服務器控件。