Search code examples
javascriptasp.netfunctionlinkbutton

Calling 2 functions using asp:linkButton


I need to call 2 functions in the onclick using the LinkButton control, it cannot execute the javascript Function :

<asp:LinkButton ID="btnVirement" value="virement" runat="server" style="color: #f15d22;" onclick="CatchLinkVirement();btnVirement_Click" ><u><b>Comment effectuer un virement ?</b></u></asp:LinkButton>

and this is the CatchLinkVirement() javaScript function :

function CatchLinkVirement() {

    var pLinkVirement = document.getElementById("btnVirement").value;
    sessionStorage.setItem("pClickVirement", pLinkVirement);
    alert(pLinkVirement);
}

and this is my codebehind :

public void btnVirement_Click(object sender, EventArgs e)
 {
        HttpContext.Current.Session["BonSavoirPopup"] = "BonAsavoirVirement";
        Response.Redirect("Mytransfers.aspx");


 }

Solution

  • You can try like this:

    OnClick="btnVirement_Click" OnClientClick="return CatchLinkVirement();"