Hello I need to pass one param to the my JS function after pressing button.
Here is my button:
<button type="button" class="btn btn-default" id="UserClick" onclick="foo(@HttpContext.Current.User.Identity.Name)">Click here to add me as a user</button>
as You can see I try to send @HttpContext.Current.User.Identity.Name
to the function foo.
Here my Foo function:
function foo(value) {
alert(value);
};
I tried sollutions from those topics: One Two
But all I get get is this error:
Uncaught SyntaxError: Unexpected token ILLEGAL
How to bypass this?
@update
All files included:
<script src="/Scripts/CreateDevice.js"></script>
<script src="/Scripts/jquery-ui.js"></script>
<script src="/Scripts/jquery-1.10.2.js"></script>
full JS file:
$(document).ready(function () {
function foo(value) {
alert(value);
};
})
I can access to the js file from page-source.