开发者

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

开发者 https://www.devze.com 2023-02-10 18:51 出处:网络
I\'m tryi开发者_开发问答ng 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:

I'm tryi开发者_开发问答ng 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();
}


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


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.


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.


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号