具有两个列表项的单选按钮的确认框... [英] Confirmation box for a radio button having two list items...

查看:85
本文介绍了具有两个列表项的单选按钮的确认框...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试为具有
的单选按钮显示确认消息 两个列表项如下:

Hello Everyone,

I am trying to dispaly a confirm msg for a radio button which is having
two list items as below:

<asp:RadioButtonList ID="rbtnDataMatch" runat="server" RepeatDirection="Horizontal"

                            style="font-size:10pt;" AutoPostBack="true"

                            onselectedindexchanged="rbtnDataMatch_SelectedIndexChanged" >
                   <asp:ListItem Text="Yes" Value="Y"></asp:ListItem>
                   <asp:ListItem Text="No" Value="N"></asp:ListItem>
                   </asp:RadioButtonList>


-----------------

在确认框中,如果单击确定",则选择"Y"项目,但是如果单击取消",则它不起作用.
我实际上希望在单击取消"时取消选中"Y"和"N"两个项目.
任何人都可以在这方面建议我...

关于


-----------------

In a confirm box, if I click "ok", the ''Y'' item is being selected but if I click "cancel", its not working..
I actually want both the items ''Y'' and ''N'' to be unchecked on clicking cancel.
anyone please suggest me on this...

Regards

推荐答案

说在按钮单击事件上显示确认框,然后...

这是示例..

我有按钮
Hi Say showing the confirm box on a button click event then...

Here is the example..

I have button
<asp:Button ID="Button2" runat="server" Text="Button" CausesValidation="false"   UseSubmitBehavior="false"/>



在标头部分(母版页的标头)中显示javascript ...



Have the javascript in the header section (master page''s header)...

<script type="text/javascript">

    function showConfirmBox(id) {
        if (confirm("You want to proceed?")) {
            var ctrl = document.getElementById(id + "_0");
            ctrl.checked = "checked";
        }
        else {
            var ctrl = document.getElementById(id + "_1");
            ctrl.checked = "checked";
        }
    }
</script>



在我的page_load事件中,我将此脚本分配给按钮,并将单选按钮列表的ID传递给脚本...



In my page_load event i am assign this script to the button and pass the id of the radio button list to the script...

Button2.Attributes.Add("onclick", "showConfirmBox('" + rbtnDataMatch.ClientID + "')");



就这样.单击按钮后,将显示确认框,并相应地选择单选按钮



thats all. Once the button click it show the confirm box and select the radio button accordingly


这篇关于具有两个列表项的单选按钮的确认框...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆