本文介绍了为什么我的确认框没有显示onclientclick按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我需要帮助,目前我有gridview with checkbox,我想显示确认框,当我点击按钮没有选中复选框。我已经尝试了一些东西,因为它没有显示onclientclick,它只显示功能里面的内容点击事件。



作为参考请在我的代码下方找到,



i need help, currently i have gridview with checkbox, i want to show confirm box when i click button with no of checkbox checked.already i try something according that its not showing the onclientclick, its only showing the function what inside the click event.

for reference pls find below my code,

<ItemTemplate>
 <asp:CheckBox ID="chkSelect" runat="server" OnCheckedChanged="chk_OnCheckedChanged" AutoPostBack="true" />
</ItemTemplate>





c#c​​ode



c# code

protected void btnReturn_Click(object sender, EventArgs e)
        {
            lblMsg.Text = string.Empty;

            List<int> selectedIds = GetSelectedIds();
            if (selectedIds.Count > 0)
            {
                for (int i = 0; i < selectedIds.Count; i++)
                {
                    Loan obj = engine.GetLoan(selectedIds[i]);
                    if (obj != null)
                    {
                        obj.LoanStatusDate = DateTime.Now;
                        obj.Status = LoanStatus.RETURNED.ToString();
                        obj.ProcessedBy = ConvertEngine.GetInteger(Session[SessionNames.CurrentUserID.ToString()].ToString());
                        obj.Remarks = "File is returned to Registry.";

                        if (engine.ReturnLoan(obj))
                            lblMsg.Text += WebEngine.GenerateMessage(obj.FileInfo.FRN + Constants.SuccessfulReturnedMessage, string.Empty, MessageType.Normal);
                        else
                            lblMsg.Text += WebEngine.GenerateMessage(obj.FileInfo.FRN + Constants.ErrorReturningMessage, string.Empty, MessageType.Error);
                    }
                }
            }

            BindGrid(0);


            Session[stateList] = null;
        }

        private List<int> GetSelectedIds()
        {
            List<int> selectedIds = new List<int>();
            for (int i = 0; i < gvList.Rows.Count; i++)
            {
                GridViewRow row = gvList.Rows[i];
                bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

                if (isChecked)
                {
                    selectedIds.Add(ConvertEngine.GetInteger(gvList.DataKeys[i].Value.ToString()));
                }
            }

            if (selectedIds.Count == 0)
                lblMsg.Text = WebEngine.GenerateMessage(Constants.ValidationRequiredSelectionMessage, string.Empty, MessageType.Info);

            return selectedIds;
        }

        protected void chk_OnCheckedChanged(object sender, EventArgs e)
        {
            int j = 0;
            for (int i = 0; i < gvList.Rows.Count; i++)
            {
                GridViewRow row = gvList.Rows[i];
                bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

                if (isChecked)
                {
                    j = j + 1;
                }
            }

            btnReturn.Attributes["OnClientClick"] = "javascript : return confirm('you selected " + j.ToString() + " checkboxes.')";

        }





现在,如果我点击按钮控件显示点击功能,但它没有显示onclientclick确认。



希望很快得到帮助:)



谢谢各位朋友



Renga



now if i click button control display the click function, but its not showing the onclientclick confirmbox.

Hope will get help soon :)

Thanks friends

Renga

推荐答案


btnReturn.OnClientClick = "return confirm('you selected " + j.ToString() + " checkboxes.');";









谢谢&此致,

AARIF SHAIKH





Thanks & Regards,
AARIF SHAIKH


这篇关于为什么我的确认框没有显示onclientclick按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:38