如何将设置标签添加到我的DNN模块?
我已将用户控件作为模块添加到DNN,但我不知道如何添加设置标签,以便某些值可配置。
答案 0 :(得分:1)
希望您使用我的Visual Studio模板,他们进行DNN模块开发,包括设置,超级简单
https://visualstudiogallery.msdn.microsoft.com/bdd506ef-d5c3-4274-bf1d-9e673fb23484
虽然不使用我的模板,但设置很简单,这里是设置的ASCX
<fieldset>
<div class="dnnFormItem">
<dnn:label ID="lblPageSize" runat="server" ControlName="txtPageSize" />
<asp:TextBox ID="txtPageSize" runat="server" />
</div>
<div class="dnnFormItem">
<dnn:label ID="lblShowCategories" runat="server" ControlName="chkShowCategories">
</dnn:label>
<asp:CheckBox ID="chkShowCategories" runat="server" />
</div>
</fieldset>
然后是
背后的代码public override void LoadSettings()
{
try
{
if (Page.IsPostBack == false)
{
//Check for existing settings and use those on this page
//Settings["SettingName"]
txtPageSize.Text = PageSize.ToString();
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
public override void UpdateSettings()
{
try
{
PageSize = Convert.ToInt32(txtPageSize.Text);
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
从我的一个开源模块中提取的示例
http://dnnsimplearticle.codeplex.com/SourceControl/latest#cs/
答案 1 :(得分:0)
要让DNN将用户控件连接到模块设置下的设置选项卡,您需要在.dnn清单文件中添加新的moduleControl定义。以下是Chris&#39; simplearticle示例模块。
<moduleControl>
<controlKey>Settings</controlKey>
<controlSrc>DesktopModules/dnnsimplearticle/Settings.ascx</controlSrc>
<supportsPartialRendering>False</supportsPartialRendering>
<controlTitle>dnnsimplearticle Settings</controlTitle>
<controlType>Edit</controlType>
<iconFile />
<helpUrl />
<viewOrder>0</viewOrder>
</moduleControl>