当我单击ASP.NET中的单选按钮时,为什么我的文本框的值没有变化?

时间:2022-04-23 03:20:22

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();
}

4 个解决方案

#1


2  

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

您是否将radiobutton的Autopostback属性设置为true?

#2


2  

Is AutoPostback set to true on the radio button?

单选按钮上的AutoPostback是否设置为true?

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.

此外,当您说“单击该单选按钮”时,您单击已经选中的单选按钮,因为这不会触发checkchanged事件。

#3


1  

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.

你在使用ASP.Net控件吗?如果是这样,您可以启用AutoPostback来实现此影响。如果您使用的是标准HTML,或者您不想启用AutoPostback,那么您需要一些其他机制来激活更改,例如表单提交。

#4


1  

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.

#1


2  

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

您是否将radiobutton的Autopostback属性设置为true?

#2


2  

Is AutoPostback set to true on the radio button?

单选按钮上的AutoPostback是否设置为true?

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.

此外,当您说“单击该单选按钮”时,您单击已经选中的单选按钮,因为这不会触发checkchanged事件。

#3


1  

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.

你在使用ASP.Net控件吗?如果是这样,您可以启用AutoPostback来实现此影响。如果您使用的是标准HTML,或者您不想启用AutoPostback,那么您需要一些其他机制来激活更改,例如表单提交。

#4


1  

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.