Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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");


 }
like image 826
anass 90 Avatar asked Mar 12 '26 01:03

anass 90


2 Answers

You can try like this:

OnClick="btnVirement_Click" OnClientClick="return CatchLinkVirement();"
like image 99
Divyang Desai Avatar answered Mar 14 '26 15:03

Divyang Desai


Write below line inside your button click handler(Server Side)

 ScriptManager.RegisterStartupScript(this, this.GetType(), "SimpleScript", "CatchLinkVirement();", true)

This way you can call javascript function from code behind.

like image 32
Krunal Sisodiya Avatar answered Mar 14 '26 15:03

Krunal Sisodiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!