Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在asp.net中选中复选框时弹出窗口_C#_Javascript_Asp.net - Fatal编程技术网

C# 在asp.net中选中复选框时弹出窗口

C# 在asp.net中选中复选框时弹出窗口,c#,javascript,asp.net,C#,Javascript,Asp.net,当用户选中复选框时,我想显示一个带有消息的确认框 因此,我有一个GridView,并且有一列用于复选框 因此,每当用户选中复选框时,我都想显示一个确认框,当用户单击该框上的“取消”时,我想取消选中该复选框 当用户按OK时,我想启动一个标准的asp.net复选框\u CheckedChanged,在这里我正在做一些数据库工作。 我不知道如何在javascript或Jquery中做到这一点 我在谷歌上找到了它,那里只有一个复选框,你可以使用ID,使用Jquery你可以显示弹出窗口。但是我有一个Gri

当用户选中
复选框时,我想显示一个带有消息的
确认框

因此,我有一个
GridView
,并且有一列用于
复选框

因此,每当用户选中
复选框时,我都想显示一个确认框,当用户单击该框上的“取消”时,我想取消选中该
复选框
当用户按OK时,我想启动一个标准的asp.net
复选框\u CheckedChanged
,在这里我正在做一些数据库工作。
我不知道如何在
javascript
Jquery
中做到这一点
我在谷歌上找到了它,那里只有一个
复选框
,你可以使用
ID
,使用
Jquery
你可以显示弹出窗口。
但是我有一个GridView,每行都有很多
复选框

请给我推荐一些工作示例或代码

谢谢

******编辑********* 这是我到目前为止得到的代码

$('#gvOrders').click(function () {
        var checked = $(this).is(':checked');
        if (checked) {
            document.getElementById("confirm_value").value = "Yes";
            if (!confirm('Are you sure you want to mark this order as received?')) {
                $(this).removeAttr('checked');
            }
        }
        else {
            document.getElementById("confirm_value").value = "No";
            if (!confirm('Are you sure you want to mark this order as  not received?')) {
                $(this).removeAttr('checked');
        }
    });
如果选中了
复选框
,则该选项目前不起作用。我不确定我在这里做错了什么

用于GRIDVIEW的HTML*********

  <asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" CssClass="gvClickCollectOrders"
    DataKeyNames="ac_OrderId" OnRowDataBound="gvOrders_RowDataBound" AllowPaging="true">
    <Columns>
        <asp:BoundField DataField="ac_OrderId" Visible="false" />
        <asp:BoundField DataField="ac_OrderNumber" HeaderText="Order No" DataFormatString="WWW{0}" />
         <asp:TemplateField HeaderText="Order Date">
            <ItemTemplate>
                <%# GetOrderDate(AlwaysConvert.ToInt(Eval("ac_OrderId"))) %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Customer Name">
            <ItemTemplate>
                <%# Eval("CustomerFirstName") %>&nbsp;<%# Eval("CustomerLastName") %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Received In Store">
            <ItemTemplate>
                <asp:CheckBox ID="cbIsReceived" runat="server" AutoPostBack="true" Checked='<%# Eval("IsReceived") %>'
                    OnCheckedChanged="cbIsReceived_CheckedChanged"/>
                    <asp:Label ID="receivedDateText" Text="" runat="server"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Collected By Customer">
            <ItemTemplate>
                <asp:CheckBox ID="cbIsCollected" runat="server" AutoPostBack="true" Checked='<%# Eval("IsCollected") %>'
                    OnCheckedChanged="cbIsCollected_CheckedChanged" />
                    <asp:Label ID="collectedDateText" Text="" runat="server"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <EmptyDataTemplate>
        <asp:Label ID="emptyGrid" runat="server" Text="there are no Click and Collect orders placed for the selected store."
            CssClass="emptyGridMessage"></asp:Label>
    </EmptyDataTemplate>
</asp:GridView>

使用jQuery

将某些类分配给gridview复选框并绑定该类上的事件

<asp:CheckBox id="chkChoice" runat="server" class="some-class" ></asp:CheckBox>    

$('.some-class').click(function () {
    var checked = $(this).is(':checked');
    if (checked) {
        document.getElementById("confirm_value").value = "Yes";
        if (!confirm('Are you sure you want to mark this order as received?')) {
            $(this).removeAttr('checked');
        }
    }
    else {
        document.getElementById("confirm_value").value = "No";
        if (!confirm('Are you sure you want to mark this order as  not received?')) {
            $(this).removeAttr('checked');

        }
    }
    //return someVariableHoldTrueOrFalseForPostBack
    //return true of false from here.
});

$('.some class')。单击(函数(){
var checked=$(this).is(':checked');
如果(选中){
document.getElementById(“确认值”).value=“是”;
如果(!confirm('您确定要将此订单标记为已收到?')){
$(this.removeAttr('checked');
}
}
否则{
document.getElementById(“确认值”).value=“否”;
如果(!confirm('您确定要将此订单标记为未收到?')){
$(this.removeAttr('checked');
}
}
//返回一些VariableHoldTrue或False用于回发
//从这里返回true或false。
});
使用javascript

您可以绑定javascript事件on复选框,它将自动应用于每行网格的所有生成复选框

<asp:CheckBox id="chkChoice" runat="server" OnClientClick="return yourFunction(this)" ></asp:CheckBox>

function yourFunction(source)
{
     return confirm("your message"); 
}

函数yourFunction(来源)
{
返回确认(“您的信息”);
}
使用jQuery

将某些类分配给gridview复选框并绑定该类上的事件

<asp:CheckBox id="chkChoice" runat="server" class="some-class" ></asp:CheckBox>    

$('.some-class').click(function () {
    var checked = $(this).is(':checked');
    if (checked) {
        document.getElementById("confirm_value").value = "Yes";
        if (!confirm('Are you sure you want to mark this order as received?')) {
            $(this).removeAttr('checked');
        }
    }
    else {
        document.getElementById("confirm_value").value = "No";
        if (!confirm('Are you sure you want to mark this order as  not received?')) {
            $(this).removeAttr('checked');

        }
    }
    //return someVariableHoldTrueOrFalseForPostBack
    //return true of false from here.
});

$('.some class')。单击(函数(){
var checked=$(this).is(':checked');
如果(选中){
document.getElementById(“确认值”).value=“是”;
如果(!confirm('您确定要将此订单标记为已收到?')){
$(this.removeAttr('checked');
}
}
否则{
document.getElementById(“确认值”).value=“否”;
如果(!confirm('您确定要将此订单标记为未收到?')){
$(this.removeAttr('checked');
}
}
//返回一些VariableHoldTrue或False用于回发
//从这里返回true或false。
});
使用javascript

您可以绑定javascript事件on复选框,它将自动应用于每行网格的所有生成复选框

<asp:CheckBox id="chkChoice" runat="server" OnClientClick="return yourFunction(this)" ></asp:CheckBox>

function yourFunction(source)
{
     return confirm("your message"); 
}

函数yourFunction(来源)
{
返回确认(“您的信息”);
}
使用以下代码

$(document).ready(function() {
 $("#gvOrders input:checkbox").click(function(e) {
    if ($(this).is(":checked")) {
        var m= confirm("your message");
        if(m !=true)
          {
              $(this).removeAttr('checked');
              e.preventDefault(); 
           }     
       });
});
使用以下代码

$(document).ready(function() {
 $("#gvOrders input:checkbox").click(function(e) {
    if ($(this).is(":checked")) {
        var m= confirm("your message");
        if(m !=true)
          {
              $(this).removeAttr('checked');
              e.preventDefault(); 
           }     
       });
});

要显示弹出复选框,请选中

1.Create a div and design a popup as per your wish in your aspx page.
2.check if the checkbox is checked or not.
3.If it is checked then call the div as popup using its id.
c#代码:

if(checkedbox.checked==true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "showpopup();", true); 
}
  function showpopup() {
    $("#popup").fadeIn('slow');
    }
脚本:

if(checkedbox.checked==true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "showpopup();", true); 
}
  function showpopup() {
    $("#popup").fadeIn('slow');
    }

其中#popup是您创建的popup div的id。

要显示pop-on复选框,请选中该复选框

1.Create a div and design a popup as per your wish in your aspx page.
2.check if the checkbox is checked or not.
3.If it is checked then call the div as popup using its id.
c#代码:

if(checkedbox.checked==true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "showpopup();", true); 
}
  function showpopup() {
    $("#popup").fadeIn('slow');
    }
脚本:

if(checkedbox.checked==true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "showpopup();", true); 
}
  function showpopup() {
    $("#popup").fadeIn('slow');
    }

其中#popup是您创建的popup div的id。

将您的html放入GridView查看我的编辑。我已经放置了我的代码,但它不起作用
gvOrders
是你的网格视图id吗?放置你的网格视图html查看我的编辑。我已经输入了我的代码,但它不起作用
gvOrders
是您的网格视图id吗?从javascript返回false将完成确认返回的操作。您必须从javascript函数返回true或false。True表示回发,false表示不回发。从javascript返回false将完成确认返回的操作。您必须从javascript函数返回True或false。对于回发为True,对于不回发为false。