Tassisto
Tassisto

Reputation: 10345

Why doesn't the value of my textbox change when I click on a radio button in ASP.NET?

I'm trying to change the value of my textbox by clicking on a radio button. But when I click on that radio button, nothing happens! Does someone know why? Here is the code:

protected void rbOpgelost_CheckedChanged(object sender, EventArgs e)
{
    tbEinddatum.Text = DateTime.Now.ToString();
}

Upvotes: 0

Views: 799

Answers (4)

Sravan Kumar
Sravan Kumar

Reputation: 1457

AutoPostback must be set to true since you are assigining text to the textbox control from the codebehind in the **rbOpgelost_CheckedChanged** property of the radio button whcich is executed on the serverside.
If autopostback is not set to true the checkedchanged event wil not be fired until a post back occurs.

Upvotes: 1

Kevin Roche
Kevin Roche

Reputation: 377

Are you using ASP.Net controls? If so you can enable AutoPostback to achieve this affect. If you're using standard HTML, or you don't want to enable AutoPostback, then you need some other mechanism to activate the change such as a form submit.

Upvotes: 1

immutabl
immutabl

Reputation: 6903

have you set the radiobutton's Autopostback property to true ?

Upvotes: 2

Fishcake
Fishcake

Reputation: 10754

Is AutoPostback set to true on the radio button?

Also when you say "click on that radio button" are you clicking on a radio button that is already checked as this won't fire the checkchanged event.

Upvotes: 2

Related Questions