Javascript 将伪数据jquery更改为倒逗号
我不知道如何将Jquery的伪代码替换为倒逗号 这很好,但是如果我将jquery伪数据替换为razor代码,我会得到错误Javascript 将伪数据jquery更改为倒逗号,javascript,jquery,asp.net,asp.net-mvc,razor,Javascript,Jquery,Asp.net,Asp.net Mvc,Razor,我不知道如何将Jquery的伪代码替换为倒逗号 这很好,但是如果我将jquery伪数据替换为razor代码,我会得到错误 jQuery('<div class="table"><input class="data-cell data-category" /><input class="data-cell data-value" type="number" step="10" /><input class="data-button delete-butto
jQuery('<div class="table"><input class="data-cell data-category" /><input class="data-cell data-value" type="number" step="10" /><input class="data-button delete-button" type="button" value="X" /><input class="data-button addnew-button" type="button" value="V" /></div>').prependTo('#data-table');
jQuery(“”).prependTo(“#数据表”);
到下面的代码
<div class="form-horizontal">
<h4>Role</h4>
<hr />
<div class="form-group">
@Html.LabelFor(model => model.user, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.user)
@Html.ValidationMessageFor(model => model.user)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.checkBox1, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.checkBox1)
@Html.ValidationMessageFor(model => model.checkBox1)
</div>
</div>
</div>
角色
@LabelFor(model=>model.user,htmlAttributes:new{@class=“controllabel col-md-2”})
@EditorFor(model=>model.user)
@Html.ValidationMessageFor(model=>model.user)
@LabelFor(model=>model.checkBox1,htmlAttributes:new{@class=“controllabel col-md-2”})
@EditorFor(model=>model.checkBox1)
@Html.ValidationMessageFor(model=>model.checkBox1)
当我试图这样做时,razor代码的@sign会导致错误,如何克服它并将反逗号中的代码替换为razor代码?不确定是编译错误还是代码编辑器中的警告 这就是我如何将javascript与Razor输出的值相结合的方法
var html = '@Html.EditorFor(x=>x.Value)';
$(html).prependTo('#somewhere');
如果您想从Razor视图中呈现整个HTML输出。你可以这样做
var html = '@Html.Partial("ViewName", Model)';
$(html).prependTo('#somewhere');
顺便说一句,这在设计上似乎很难闻
或者,使用ajax$。访问返回PartialView的操作url会更简单
$.get('@Url.Action("ActionName")', function(html){
$(html).prependTo('#somewhere');
});
在razor代码中找不到与javascript相关的任何部分。哪一行导致了错误?@PasitR.-如果你使用我放在razor中的代码并用它替换Jquery的倒逗号,你会看到错误,因为它不会忽略@sign…知道如何克服它吗?非常感谢你的支持!我可以在一个驱动器中共享项目吗?例如,当我输入您在第一个驱动器中提供的代码时,代码编辑器中出现了错误