views:

11

answers:

1

I make a simple Visual web part and deployed it, and put it on a page. I have a button included in the web part, I want to output some text, like Hello World, output somewhere in SharePoint, so I can do some code tracing when I need to. I assume there is a method for the button, that is called when I click it? It is there that I want to put some code to output text. How is this done in C# code in a web part in SharePoint 2010?

A: 

You can create an event handler for your button by double-clicking it. To display some text in a webpart, just add a label and set its text property.

protected void MyButton_Click(object sender, EventArgs e)
{
    MyLabel.Text = "Hello World!";
}

Of course, you could also just use the debugger in Visual Studio if you want to debug something. ;-)

Tom Vervoort

related questions