双击转发器上的Linkbutton?

时间:2011-04-26 02:47:29

标签: c# asp.net repeater

我在转发器上有链接按钮。我的问题是如何在转发器内双击链接按钮而不是一次点击?

这是我的代码:

    <td class="style2">
    <asp:LinkButton ID="lblName" runat="server" Text='<%# Bind("Name") %>' CommandName="Name" CommandArgument='<%# Eval("Code") %>'>
    </asp:LinkButton></td> 

C#

protected void rptrInsurance_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                switch (e.CommandName)
                {
                    case "Delete":
                        {
                            HCSInsurance oInsuranceDelete = new HCSInsurance();
                            Insurance oInsurance = new Insurance();

                            List<InsuranceLabel> lstName = oInsuranceDelete.RetrieveInsuranceList();
                            foreach (InsuranceLabel item in lstName)
                            {
                                var code = e.CommandArgument;
                                if (item.InsuranceCode.ID == code.ToString())
                                {
                                    oInsurance.InsuranceCode = item.InsuranceCode;
                                    oInsuranceDelete.DeleteInsurance(oInsurance);
                                    bind();
                                }
                            }

                        }
                        break;
                    case "Edit":
                        {
                            Session["InsuranceCodeID"]= e.CommandArgument.ToString();  
                            Response.Redirect("~/InsuranceCarrierNew.aspx");
                        }
                        break;
                    default:
                        {
                           //bind();
                            HCSInsurance oHCSInsurance = new HCSInsurance();
                            Insurance oInsurance = new Insurance();
                            string code = Convert.ToString(e.CommandArgument);
                            oInsurance = oHCSInsurance.RetrieveInsurance(code);
                            Labelvisible();
                            //string

                            lblName.Text = oInsurance.Name;
                            lblAddress.Text = oInsurance.Address1;
                            lblCity.Text = oInsurance.City;
                            lblState.Text = oInsurance.State;
                            lblZip.Text = oInsurance.Zip;
                            lblDphone.Text = oInsurance.ContactTelephone;
                            lblDfax.Text = oInsurance.ContactFax;

                        }
                        break;
                }
            }

        }

        catch (Exception ex)
        {

        }

    }

1 个答案:

答案 0 :(得分:0)

如您所知,您希望实现的目标存在于客户端,则双击事件有jQuery API,如:

$('id').dblclick(function() {
     // Call something here.
});

这样做的缺点是,您可能希望更改实现AJAX调用而不是回发,也可以只提交表单并编辑后端代码的必要参数。