我的 webpart 应该有很多关于 answertype 下拉列表的问题。在设置中,问题可以使用工具部件进行配置。编写和阅读一个问题的设置。我不知道代码如何解决 x-more 问题(我必须在哪种方法中使用冗余代码 - 我可以在哪里以及如何封装代码?你有给我提示,或者你知道一个有趣的网站吗?我希望你能理解我的问题;否则我会写更多细节......
谢谢
此外,来自工具部分的(基本部分)代码:
public class FeedbackToolpart : ToolPart
{
Label ques1Lab, ans1Lab, typ1Lab;
DropDownList ddList;
List<Question> outputList;
...
public FeedbackToolpart() : base() { this.Title = "Bewertungseinstellungen"; }
protected override void CreateChildControls()
{
parentWebPart = (Feedbackwebpart)this.ParentToolPane.SelectedWebPart;
...
ddList = new DropDownList();
ddList.ID = "TheCheckBoxList";
ddList.Items.Add("");
ddList.Items.Add("Schieberegler");
ddList.Items.Add("Checkboxen");
ddList.Items.Add("Textbox");
ddList.SelectedIndexChanged += new EventHandler(ddList_SelectedIndexChanged);
ddList.AutoPostBack = true;
ddList.SelectedValue = (parentWebPart.MyValue != null) ? parentWebPart.MyValue[0].answType : "Textbox";
this.Controls.Add(pan);
base.CreateChildControls();
}
protected void ddList_SelectedIndexChanged(object sender, EventArgs e) { ... }
public override void ApplyChanges()
{
parentWebPart = (Feedbackwebpart)this.ParentToolPane.SelectedWebPart;
outputList = new List<Question>();
outputList.Add(new Question(texQuestion.Text, texAnswers.Text, ddList.SelectedValue));
parentWebPart.MyValue = outputList;
}
}