【发布时间】:2011-06-24 16:00:21
【问题描述】:
错误:无法显示或导入此页面上的 Web 部件或 Web 窗体控件。找不到该类型或未将其注册为安全类型。
在我的 webpart 上添加属性后出现此错误。当我删除该属性时,webpart 正在工作,但是当我将其添加回来时,错误就出现了。
这是我在代码中添加的属性。
/// <summary>
/// Property that contains the maximum number of answers allowed in the question
/// </summary>
/// <value>The number of answers allowed</value>
const int default_intPollMaxAnswers = 2;
private int intPollMaxAnswer = default_intPollMaxAnswers;
[WebBrowsable(true)]
[WebDisplayName("Maximum No. of Answers")]
[WebDescription("Total no. of answers")]
[Category("Poll settings")]
[Personalizable(PersonalizationScope.Shared)]
[DefaultValue(default_intPollMaxAnswers)]
public int SPUserPollMaxAnswer
{
get { return intPollMaxAnswer; }
set { intPollMaxAnswer = value; }
}
这是我使用我的财产的方法.. 虽然我确信这不会影响我的 webpart,因为我当时评论了这个方法......
private void InsertPollModalDialogForm()
{
this.Controls.Add(new LiteralControl(@"<div id=""divPollDialogForm"" title=""User Poll"" style=""font-size:8pt; display:none;"">"));
this.Controls.Add(new LiteralControl(@"<table border=""0"" style=""width: 345px; height: 73px"">"));
this.Controls.Add(new LiteralControl(@"<tr>"));
this.Controls.Add(new LiteralControl(@"<td style=""width: 122px"">Poll title </td>"));
this.Controls.Add(new LiteralControl(@"<td><textarea title=""What is your poll question?"" class=""text ui-widget-content ui-corner-all"" style=""width:100%;"" id=""txtPollQuestion"" rows=""2"" cols=""4""/></td>"));
this.Controls.Add(new LiteralControl(@"</tr>"));
for (int intCountAnswers = 1; intCountAnswers < intPollMaxAnswer; intCountAnswers++)
{
this.Controls.Add(new LiteralControl(@"<tr>"));
this.Controls.Add(new LiteralControl(@"<td style=""width: 122px; height: 43px"" valign=""top"">Answer </td>"));
this.Controls.Add(new LiteralControl(
string.Format(@"<td style=""height: 43px""><input type=""text""
class=""clsAnswers"" id=""txtAnswer{0}""
style=""width:200px""/></td>",
intCountAnswers
)));
this.Controls.Add(new LiteralControl(@"</tr>"));
}
this.Controls.Add(new LiteralControl(@"<tr><td colspan=""2""><br /></td></tr>"));
this.Controls.Add(new LiteralControl(@"</table>"));
this.Controls.Add(new LiteralControl(@"</div>"));
}
下面是错误页面的截图..
我希望有人可以帮助我解决我的问题。提前谢谢!
【问题讨论】:
-
您能否提供使用此属性值的代码,因为它们在您的属性声明中没有问题
-
@Ashutosh:嗨,我已经编辑了我的帖子。希望能帮助到你。谢谢:)
-
您是否在 web.config 中将您的 webpart 注册为更安全的控件?即'
' -
如果您将属性重命名为其中没有“SPUser”的名称会怎样?
-
其实属性名完全没有问题...我什至尝试过你的建议,但结果没有任何区别。顺便谢谢。
标签: c# sharepoint-2007 properties web-parts