c# - Call CodeBehind Method from JavaScript with parameter -
i'm trying call code behind method javascript code. works fine, not sure how can pass javascript parameter method. if put value between parenthesis, related codebehind context rather script context. solution pass parameter?
javascript:
var arg = this.id <% setselection(arg); %>
c#:
[webmethod] public void setselection(string productid) { session["selection"] = productid }
i error of course: cs0103: name 'arg' not exist in current context
your setselection(arg)
call not calling code behind javascript. getting called on server side, before html response output browser, way before javascript executes. arg
treated c# variable.
if want make call javascript, need use ajax. see this example.
Comments
Post a Comment