使用radiobutton如何执行类函数 [英] using radiobutton how to execute the class function
问题描述
Private void GetDetails()
{
//这里编写代码
}
private void CourseDetails()
{
//这里写的代码
}
< br $>
i有一个显示按钮如下;
i有两个单选按钮如下radioobutton1和radiobutton2。
如果单选按钮1选中true表示GetDetails函数想要执行。
如果单选按钮2选中true表示CourseDetails函数想要执行。
我怎么能在Show Button中编写代码。
我怎样才能在c#中使用asp.net。
请帮帮我。
问候,
Narasiman P.
你可以使用OnCheckedChanged
要做的事情:
< asp:radiobutton id = radiobutton1 groupname = Group1 text = 是 value = 是 runat = server oncheckedchanged = Group1_CheckedChanged xmlns:asp = #unknown / >
< asp: radiobutton id = radiobutton2 groupname = Group1 text = 无 value = 否 runat = server oncheckedchanged = Group1_CheckedChanged xmlns:asp = #unknown / >
受保护 void Group1_CheckedChanged( Object sender,EventArgs e)
{
if (radiobutton1.Checked){
GetDetails();
}
if (radiobutton2.Checked){
CourseDetails();
}
}
详情请参阅:
http://stackoverflow.com/questions/8095256/asp-net-radio-按钮更改 [ ^ 一>
Private void GetDetails()
{
//written code here
}
private void CourseDetails()
{
//written code here
}
i have one show button as follows;
i have two radio button as follows radiobutton1 and radiobutton2.
if radio button1 checked true means GetDetails function want to execute.
if radio button2 checked true means CourseDetails function want to execute.
for that how can i write the code in the Show Button.
for that how can i do using asp.net in c#.
please help me.
Regards,
Narasiman P.
You can useOnCheckedChanged
event to do that:
<asp:radiobutton id="radiobutton1" groupname="Group1" text="Yes" value="Yes" runat="server" oncheckedchanged="Group1_CheckedChanged" xmlns:asp="#unknown" /> <asp:radiobutton id="radiobutton2" groupname="Group1" text="No" value="No" runat="server" oncheckedchanged="Group1_CheckedChanged" xmlns:asp="#unknown" />
protected void Group1_CheckedChanged(Object sender, EventArgs e) { if (radiobutton1.Checked) { GetDetails(); } if (radiobutton2.Checked) { CourseDetails(); } }
For more details Refer :
http://stackoverflow.com/questions/8095256/asp-net-radio-button-change[^]
这篇关于使用radiobutton如何执行类函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!