0

I am trying parse parameter from javaScript to C# method in asp.net

function handleClick(event) {
       var id=event.item.values.value;
       alert(<%MyMethod("id")%>);
    }

it give me nothing

  • JavaScript is running in the browser. C# is running on the server. You need to use ajax to go between the two. – Matt Ball Nov 20 '15 at 20:38
  • What exactly are you attempting to accomplish here? – JD Davis Nov 20 '15 at 20:38
  • You wouldn't call C# method from Javascript (at least in your context of ASP pages) – vsnyc Nov 20 '15 at 20:39
  • @MattBall How can i do that? – Ishant Ahuja Nov 20 '15 at 20:41
  • The block in between `<%` and `%>` only runs on the server and it sends down to the client. It's one way. You can't use that to send stuff back. You need to do a form with a POST or make a url with a query string to get data back to the server. – toddmo Nov 21 '15 at 02:15

0 Answers0