錯誤:無法顯示或導入此頁面上的Web部件或Web窗體控件。找不到類型,或者未註冊爲安全類型。Web部件錯誤:無法顯示或導入此頁面上的Web部件或Web窗體控件
在我的web部件上添加了一個propety後出現此錯誤。當我刪除該屬性的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>"));
}
下面是錯誤頁面的捕獲畫面..
我希望有人在那裏可以幫助我解決我的問題。先謝謝你!
你可以提供代碼,你消耗這個屬性值,因爲他們在你的財產聲明沒有問題 – 2011-02-10 07:09:09
@Ashutosh:嗨,我已經編輯我的文章。希望能幫助到你。感謝:) – 2011-02-10 07:37:27