arshimen
arshimen

Reputation: 1

How write input with Razor in javascript?

How Writre Input By Razor In Javascript?

@Html.TextBox("Name",null,new{@class="form-control"})

Upvotes: -5

Views: 677

Answers (2)

Christian Boyer
Christian Boyer

Reputation: 48

You can't write Razor in JavaScript because Razor is server-side and JavaScript is client-side.

Upvotes: 0

Adrita Sharma
Adrita Sharma

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

Related Questions