Reputation: 1
How Writre Input By Razor In Javascript?
@Html.TextBox("Name",null,new{@class="form-control"})
Upvotes: -5
Views: 677
Reputation: 48
You can't write Razor in JavaScript because Razor is server-side and JavaScript is client-side.
Upvotes: 0
Reputation: 22203
You can try this:
Write a div with a id, in which you want your HTML
Eg:
<div id="nameDiv"></div>
Then in your script, write this:
<script>
var nameDivInput= '<input type="text" class="form-control" id="name"/>';
document.getElementById("nameDiv").append(nameDivInput);
</script
Upvotes: 0