Button not performing action
OK, I have a button that when pushed, performs various tasks (gets info from an XML file on an http server actually.) Before it does that I want it to show some output (for example, "please wait, getting file"). However... it's not doing that.
Here's the button:
Code:
//
// buttonGetName
//
this.buttonGetName.Location = new System.Drawing.Point(41, 38);
this.buttonGetName.Name = "buttonGetName";
this.buttonGetName.Size = new System.Drawing.Size(128, 23);
this.buttonGetName.TabIndex = 0;
this.buttonGetName.Text = "Get line-in name";
this.buttonGetName.Click += new System.EventHandler(this.buttonGetName_Click);
And here's the onclick handling code:
Code:
// if get name is clicked...
private void buttonGetName_Click(object sender, EventArgs e)
{
labelInfo.Text = "Getting name..."; // WHY DOES THIS NOT HAPPEN?!
labelHTML.Text = ""; // or this actually.
string SoapAction = "SOAPACTION: \"urn:schemas-upnp-org:service:AudioIn:1#GetAudioInputName\"";
string Data =
"<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+" <s:Body>"
+" <u:GetAudioInputName xmlns:u=\"urn:schemas-upnp-org:service:AudioIn:1\" />"
+" </s:Body>"
+"</s:Envelope>";
string name = LineInName(SoapAction, Data);
// if error, display, otherwise show line-in name
if (name.Substring(0, 6) == "ERROR:")
{
labelHTML.Text = name;
labelInfo.Text = "Error.";
} else {
labelInfo.Text = "Got name.";
textBoxName.Text = name;
}
}
LineInName() is a function that actually connects to the HTTP server, sends a request, and recieves a request (which then gets output to textBoxName) - unless it's an error, which is then handled.
Basically, I want to click buttonGetName, then I want labelInfo to show "Getting name..." (and clear labelHTML too) - and then access my LineInName() function. However, it's taking a while to get the file and giving no feedback while it does this.