You create a Web Part that contains the following code segment. (Line numbers are included for reference only.)
01 public class WebPart1 : WebPart
02 {
03 public WebPart1() {}
04
05 protected override void CreateChildControls()
06 {
07 Button clickButton = new Button();
08
09 base.CreateChildControls();
10 }
11
12 protected override void RenderContents(HtmlTextWriter writer)
13 {
14
15 base.RenderContents(writer);
16 }
17 }
You discover that the clickButton button does not appear.
You need to ensure that clickButton appears.
What should you do?
A.
Delete line 09.
B.
Move line 07 to line 14.
C.
Add the following line of code at line 08:
Controls.Add(clickButton);
D.
Add the following line of code at line 08:
clickButton.Page = this.Page;
Explanation:
MNEMONIC RULE: “create Button, then Add Button”Create a Custom Web Part for SharePoint 2010
http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/SharePoint 2010 Visual Web Parts
http://httpcode.com/blogs/PermaLink,guid,357e4853-9a75-4962-ad68-1e07bcf40bb8.aspx