Skip to content

Instantly share code, notes, and snippets.

@burkeholland
Created August 8, 2011 14:48
Show Gist options
  • Save burkeholland/1131884 to your computer and use it in GitHub Desktop.
Save burkeholland/1131884 to your computer and use it in GitHub Desktop.
[ToolboxItemAttribute(false)]
public class HelloWorldWebPart : WebPart {
TextBox _firstName;
TextBox _lastName;
Button _sayHello;
Label _result;
protected override void CreateChildControls() {
_firstName = new TextBox() { ID = "txtFirstName" };
this.Controls.Add(_firstName);
_lastName = new TextBox() { ID = "txtLastName" };
this.Controls.Add(_lastName);
_sayHello = new Button() { ID = "btnSayHello", Text = "Say Hello" };
_sayHello.Click += new EventHandler(_sayHello_Click);
this.Controls.Add(_sayHello);
_result = new Label() { ID = "lblResult" };
this.Controls.Add(_result);
}
void _sayHello_Click(object sender, EventArgs e) {
_result.Text = "Hello " + _firstName.Text + " " + _lastName.Text;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment