how can I call a serversidefunction from javascript ?

this is my serverside code, how can I call this from  javascript and pass in a parameter.

protected void copyLine(string id)
       if(id == "1")

Open in new window

Who is Participating?
I may be wrong, but I'm not 100% sure that this is actually possible, due to the JavaScript's limitations as a "language", Why not just do this all in ASP.NET?

Again, I may be wrong; I'm not a JavaScript fanatic, or even a fan, for that matter.
tech_questionAuthor Commented:
how can I do that  - can you please post an example code? I am adding dynamically code to the onclick event of a linkbutton - but by default it is calculating it as a client side onclick - how can we make it to respect it as a serverside function ?
tech_questionAuthor Commented:
would this have any security impact in me doing this way ?
You are going to expose certain methods to be called from javascript using [WebMethod]. You can even control the unnecessary data by validating the input. These methods can't be called from other pages. Only the current page can invoke the server methods.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.