Filip Nilsson
Filip Nilsson

Reputation: 407

Change value and text of button

I have a textbox and a button with an onClick event connected to it, and when the button is clicked once I want to change the text of the button and clear the textbox. How can i accomplish this?

Upvotes: 0

Views: 339

Answers (2)

Mubarek
Mubarek

Reputation: 2689

This needs you to know about TextBox and its properties. Normally the value of a textbox you use its Text property as TextBox1.Text. In your case you put this statement in the button's click event

string txtValue=TextBox1.Text;
TextBox1.Text=string.Empty;

To see how to use TextBox and its properties. This can help

Upvotes: 1

Jonathan Wood
Jonathan Wood

Reputation: 67195

If you want to do this on a postback (a complete refresh of the page), simply put code in your button click handler to set these values. For example, textbox.Text = string.Empty;

If you want to set it on the client side (without refreshing the page), then you'd need to use client script such as JavaScript.

Upvotes: 1

Related Questions