How can i combine razor and java script
I want to do this :
@{Session["type"] = $(this).attr("id");}
I do that, but i got an error.
I've tried this but it's not work for me.
using javascript variable in MVC3 Razor view engine
And here is my code:
$(document).on("click", ".btn-group", function() {
var t = $(this).attr("id");
var text = "@{Session["type"] = "JSVar";}";
text = text.replace("JSVar", t);
});
Can any one give me suggestion?
Sessionis server side. Javascript is client side. If you want to set the value of session property, then you need to send the data to the server.