How to call javascript method in asp.net web application

前端 未结 4 1401
无人及你
无人及你 2021-01-21 01:26

I want to use a javascript function inside a c# function

protected void button1_Click(object sender,EventArgs e){
    //javascript function call ex.
    /*
    b         


        
4条回答
  •  渐次进展
    2021-01-21 01:45

    If you're simply trying to create the functionality of letting the server know that a button was clicked, you're over complicating things. If you really need to dynamically insert Javascript then what Adam mentioned is worth looking into. But I highly doubt that this is the correct approach for what you're trying to do.

    You should really only dynamically insert Javascript when you're worried about performance AND you have a lot of content to send.

    If dynamically inserting Javascript (ie. lazy loading) is not your main concern, then here is a very simple example of what most folks would usually do to achieve the functionality you're aiming for.

提交回复
热议问题