Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在.NETMVC4中使用jquery排列文本框?_Jquery_Html_.net_Jquery Plugins_Asp.net Mvc 4 - Fatal编程技术网

如何在.NETMVC4中使用jquery排列文本框?

如何在.NETMVC4中使用jquery排列文本框?,jquery,html,.net,jquery-plugins,asp.net-mvc-4,Jquery,Html,.net,Jquery Plugins,Asp.net Mvc 4,我有一个任务来安排页面中的文本框。这是我的html代码。此代码是自动生成的。我想通过创建默认设置来安排文本框的位置 @model Resume.Models.Resume @{ ViewBag.Title = "Create"; } <h2>Create</h2> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <le

我有一个任务来安排页面中的文本框。这是我的html代码。此代码是自动生成的。我想通过创建默认设置来安排文本框的位置

@model Resume.Models.Resume

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Resume</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Gender)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Gender)
            @Html.ValidationMessageFor(model => model.Gender)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address)
            @Html.ValidationMessageFor(model => model.Address)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DateOfBirth)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DateOfBirth)
            @Html.ValidationMessageFor(model => model.DateOfBirth)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Age)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Age)
            @Html.ValidationMessageFor(model => model.Age)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.City)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.City)
            @Html.ValidationMessageFor(model => model.City)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Country)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Country)
            @Html.ValidationMessageFor(model => model.Country)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.HighSchool)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.HighSchool)
            @Html.ValidationMessageFor(model => model.HighSchool)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CollegePer)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CollegePer)
            @Html.ValidationMessageFor(model => model.CollegePer)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Qualification)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Qualification)
            @Html.ValidationMessageFor(model => model.Qualification)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DegreeYearOfPassout)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DegreeYearOfPassout)
            @Html.ValidationMessageFor(model => model.DegreeYearOfPassout)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PreviousCompanyName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PreviousCompanyName)
            @Html.ValidationMessageFor(model => model.PreviousCompanyName)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
@model Resume.Models.Resume
@{
ViewBag.Title=“创建”;
}
创造
@使用(Html.BeginForm()){
@Html.ValidationSummary(true)
简历
@LabelFor(model=>model.FirstName)
@EditorFor(model=>model.FirstName)
@Html.ValidationMessageFor(model=>model.FirstName)
@LabelFor(model=>model.LastName)
@EditorFor(model=>model.LastName)
@Html.ValidationMessageFor(model=>model.LastName)
@LabelFor(model=>model.Gender)
@EditorFor(model=>model.Gender)
@Html.ValidationMessageFor(model=>model.Gender)
@LabelFor(model=>model.Address)
@EditorFor(model=>model.Address)
@Html.ValidationMessageFor(model=>model.Address)
@LabelFor(model=>model.Phone)
@EditorFor(model=>model.Phone)
@Html.ValidationMessageFor(model=>model.Phone)
@LabelFor(model=>model.Email)
@EditorFor(model=>model.Email)
@Html.ValidationMessageFor(model=>model.Email)
@LabelFor(model=>model.DateOfBirth)
@EditorFor(model=>model.DateOfBirth)
@Html.ValidationMessageFor(model=>model.DateOfBirth)
@LabelFor(model=>model.Age)
@EditorFor(model=>model.Age)
@Html.ValidationMessageFor(model=>model.Age)
@LabelFor(model=>model.City)
@EditorFor(model=>model.City)
@Html.ValidationMessageFor(model=>model.City)
@LabelFor(model=>model.Country)
@EditorFor(model=>model.Country)
@Html.ValidationMessageFor(model=>model.Country)
@LabelFor(model=>model.HighSchool)
@EditorFor(model=>model.HighSchool)
@Html.ValidationMessageFor(model=>model.HighSchool)
@LabelFor(model=>model.CollegePer)
@EditorFor(model=>model.CollegePer)
@Html.ValidationMessageFor(model=>model.CollegePer)
@LabelFor(model=>model.Qualification)
@EditorFor(model=>model.Qualification)
@Html.ValidationMessageFor(model=>model.Qualification)
@LabelFor(model=>model.DegreeYearOfPassout)
@EditorFor(model=>model.DegreeYearOfPassout)
@Html.ValidationMessageFor(model=>model.DegreeYearOfPassout)
@LabelFor(model=>model.PreviousCompanyName)
@EditorFor(model=>model.PreviousCompanyName)
@Html.ValidationMessageFor(model=>model.PreviousCompanyName)

} @ActionLink(“返回列表”、“索引”) @节脚本{ @Scripts.Render(“~/bundles/jqueryval”) }

我该怎么做?是否有jquery插件或jquery代码?

使用jquery,您可以按id获取元素(您必须设置它们的id),并操作它们的css属性

我说的是id,以防你需要把它们放在不同的位置。如果需要移动同一类的所有对象,可以按类获取它们(更改a的#选择器)

jquery代码如下所示:

$('#ID').css({ 'ATRIBUTE NAME': 'VALUE' });
那么,让我们看一个例子

如果要更改id=myElement的元素的显示,请执行以下操作

$('#myElement').css({ 'display': 'none' });

您可以找到相应的文档,或者如果您将ID添加到元素中,您可以在CSS中执行此操作。通过指定ID

比如:

#ID_ELEMENT
{
 attribute : ...;
}

如果您想避免编写javascript,那么这些元素中的每一个都有类,这样您就可以很容易地在css中将它们作为目标。如果您需要为特定的标记执行任何操作,那么您需要将ID添加到生成的标记中,或者使用一些更高级的css选择器技术,但由于生成的代码使其更健壮,我建议使用ID,因为您不能授权元素的顺序。

定义css类

div.editor-field input[type=text]
{
 margin: 0 0 0 0; //just a sample position
 padding: 0 0 0 0;
 ....
}
然后每次你掉下去

 <div class="editor-field">
            @Html.EditorFor(model => model.CollegePer)

        </div>

@EditorFor(model=>model.CollegePer)

如果您使用此
@Html.EditorFor(model=>model.Age)
,则页面上元素的id将为#Age


#年龄{
你的css在这里
}
使用此样式来安排每一次。。

实际上,我想在中自动创建它。我知道你怎么说的,怎么说?你能再详细解释一下吗?另外,您应该在描述中添加:)是否可以使用脚手架。
<style>
#age {
ur css here 
}
</style>
use this style to arrange for each once ..