0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I want to do it on a postback.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.