我正在开发一个使用JQuery实现其视图的C#/ .NET网络应用程序,我发现在输入标记中使用double值会出现一些问题。
例如,我在我的视图中有以下代码段:
<div class="ui-field-contain">
<label for="Test">Test:</label>
<input type="number" runat="server" id="Test" name="Test" min="0" max="10" step=".1" value="@Model.test" />
</div>
@ Model.test 模型对象字段中的值是 2.3 (我使用调试器看到它)但是在我的输入标记中看不到任何内容。
我认为问题可能与JQuery使用逗号分隔整数和小数的事实有关,而不是我有。符号
你能帮我解决这个问题吗?
编辑1:这是我的整个观点
@model DataModel.Vulnerability.Vuln
@{
ViewBag.Title = "Edit";
Layout = "~/Views/Shared/MasterPageMobile.cshtml";
}
<h2 style="float: right;">Published: @(Model.Published.Value.ToShortDateString())</h2>
<h2>Vulnerabilità: @Model.CVE</h2>
<style>
.mytabVuln {
width: 20% !important; /* 14.2% for 5 tabs wide */
clear: none !important; /* Prevent line break caused by ui-block-a */
}
</style>
<div id="MyTabs" data-role="tabs">
<div data-role="navbar">
<ul>
<li class="mytabVuln"><a href="#tab-0" data-ajax="false">General</a></li>
<li class="mytabVuln"><a href="#tab-1" data-ajax="false">Systems</a></li>
<li class="mytabVuln"><a href="#tab-2" data-ajax="false">Fixes/Solutions/Mitigating</a></li>
<li class="mytabVuln"><a href="#tab-3" data-ajax="false">Change Logs/References</a></li>
<li class="mytabVuln"><a href="#tab-4" data-ajax="false">OVALs</a></li>
</ul>
</div>
<!-- TAB-0: INFORMAZIONI GENERALI: -->
<div id="tab-0" class="ui-body ui-body-a">
@using (Html.BeginForm("Edit", "Vulnerability", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(false)
<input type="hidden" name="Id" value="@Model.Id" />
<div class="ui-field-contain">
<label for="Title">Title:</label>
<input type="text" id="Title" name="Title" value="@Model.Title" data-clear-btn="true" />
</div>
<div class="ui-field-contain">
<label for="Test">Severity:</label>
<input type="number" id="Test" name="Test" min="0" max="10" step=".1" value="@Model.test" />
</div>
<div class="ui-field-contain">
<label for="BugTraqID">BugTraqID:</label>
<input type="number" id="BugTraqID" name="Title" min="0" step="1" value="@Model.BugTraqID" />
</div>
<div class="ui-field-contain">
<label for="StatusID">StatusID:</label>
<input type="number" id="StatusID" name="Title" min="0" max="10" step="0.1" value="@Model.StatusID" />
</div>
<div class="ui-field-contain">
<label for="Remote">Remote:</label>
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend></legend>
<input name="Remote" id="radio-Remote-Yes" value="Yes" @(Model.Local == "Yes" ? "checked" : "") type="radio">
<label for="radio-Remote-Yes">Yes</label>
<input name="Remote" id="radio-Remote-No" value="No" @(Model.Local == "No" ? "checked" : "") type="radio">
<label for="radio-Remote-No">No</label>
<input name="Remote" id="radio-Remote-Null" value="NULL" @(Model.Local == "" ? "checked" : "") type="radio">
<label for="radio-Remote-Null">Null</label>
</fieldset>
</div>
<div class="ui-field-contain">
<label for="Local">Local:</label>
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend></legend>
<input name="Local" id="radio-Local-Yes" value="Yes" @(Model.Local == "Yes" ? "checked" : "") type="radio">
<label for="radio-Local-Yes">Yes</label>
<input name="Local" id="radio-Local-No" value="No" @(Model.Local == "No" ? "checked" : "") type="radio">
<label for="radio-Local-No">No</label>
<input name="Local" id="radio-Local-Null" value="NULL" @(Model.Local == "" ? "checked" : "") type="radio">
<label for="radio-Local-Null">Null</label>
</fieldset>
</div>
<div class="ui-field-contain">
<label for="Credibility">Credibility:</label>
<input type="text" id="Credibility" name="Credibility" value="@Model.Credibility" />
</div>
<div class="ui-field-contain">
<label for="Classification">Classification:</label>
<input type="text" id="Classification" name="Classification" value="@Model.Classification" />
</div>
<div class="ui-field-contain">
<label for="Availability">Availability:</label>
<input type="text" id="Availability" name="Availability" value="@Model.Availability" />
</div>
<div class="ui-field-contain">
<label for="Ease">Ease:</label>
<input type="text" id="Ease" name="Ease" value="@Model.Ease" />
</div>
<div class="ui-field-contain">
<label for="Authentication">Authentication:</label>
<input type="text" id="Authentication" name="Authentication" value="@Model.Authentication" />
</div>
<h3 class="ui-bar ui-bar-a ui-corner-all">CVSS2</h3>
<div class="ui-body ui-body-a ui-corner-all">
<div data-role="fieldcontain">
<label for="slider">CVSS2_BaseScore:</label>
<input type="range" name="slider" id="slider" min="0" max="10" step=".1" value="@String.Format(new System.Globalization.CultureInfo("en-GB"), "{0:N1}", Model.CVSS2_BaseScore)" />
</div>
<div class="ui-field-contain">
<label for="CVSS2_TemporalScore">CVSS2_TemporalScore:</label>
<input type="text" id="CVSS2_TemporalScore" name="CVSS2_TemporalScore" value="@Model.CVSS2_TemporalScore" />
</div>
<div class="ui-field-contain">
<label for="CVSS2_BaseVector">CVSS2_BaseVector:</label>
<input type="text" id="CVSS2_BaseVector" name="CVSS2_BaseVector" value="@Model.CVSS2_BaseVector" />
</div>
<div class="ui-field-contain">
<label for="CVSS2_TemporalVector">CVSS2_TemporalVector:</label>
<input type="text" id="CVSS2_TemporalVector" name="CVSS2_TemporalVector" value="@Model.CVSS2_TemporalVector" />
</div>
<div class="ui-field-contain">
<label for="CVSS1_BaseScore">CVSS1_BaseScore:</label>
<input type="text" id="CVSS1_BaseScore" name="CVSS1_BaseScore" value="@Model.CVSS1_BaseScore" />
</div>
<div class="ui-field-contain">
<label for="CVSS1_TemporalScore">CVSS1_TemporalScore:</label>
<input type="text" id="CVSS1_TemporalScore" name="CVSS1_TemporalScore" value="@Model.CVSS1_TemporalScore" />
</div>
</div>
<h3 class="ui-bar ui-bar-a ui-corner-all">NVD CVSS2</h3>
<div class="ui-field-contain">
<label for="NVD_CVSS2_BaseScore">NVD_CVSS2_BaseScore:</label>
<input type="text" id="NVD_CVSS2_BaseScore" name="NVD_CVSS2_BaseScore" value="@Model.NVD_CVSS2_BaseScore" />
</div>
<div class="ui-field-contain">
<label for="NVD_CVSS2_ComponentString">NVD_CVSS2_ComponentString:</label>
<input type="text" id="NVD_CVSS2_ComponentString" name="NVD_CVSS2_ComponentString" value="@Model.NVD_CVSS2_ComponentString" />
</div>
<div class="ui-field-contain">
<label for="ImpactRating">ImpactRating:</label>
<input type="number" id="ImpactRating" name="ImpactRating" min="0" max="10" step="0.1" value="@Model.ImpactRating" />
</div>
<div class="ui-field-contain">
<label for="EaseofExploit">EaseofExploit:</label>
<input type="number" id="EaseofExploit" name="EaseofExploit" min="0" max="10" step="1" value="@Model.EaseofExploit" />
</div>
<div class="ui-field-contain">
<label for="UrgencyRating">UrgencyRating:</label>
<input type="number" id="UrgencyRating" name="UrgencyRating" min="0" max="10" step="0.1" value="@Model.UrgencyRating" />
</div>
<div class="ui-field-contain">
<label for="LastChange">LastChange:</label>
<textarea data-clear-btn="true" name="LastChange" id="LastChange" data-mini="true" data-inline="true" required="required" data-value="@Model.LastChange" placeholder = "Inserire qui il LastChange" rows="5" cols="40">@Model.LastChange</textarea>
</div>
<div class="ui-field-contain">
<label for="ShortSummary">ShortSummary:</label>
<textarea data-clear-btn="true" name="ShortSummary" id="ShortSummary" data-mini="true" data-inline="true" data-role="true" required="required" data-value="@Model.ShortSummary" placeholder = "Inserire qui lo ShortSummary" rows="5" cols="40">@Model.ShortSummary</textarea>
</div>
<div class="ui-field-contain">
<label for="Impact">Impact:</label>
<textarea data-clear-btn="true" name="Impact" id="Impact" data-mini="true" data-inline="true" required="required" data-value="@Model.Impact" placeholder = "Inserire qui l'Impact" rows="5" cols="40">@Model.Impact</textarea>
</div>
<div class="ui-field-contain">
<label for="TechnicalDescription">TechnicalDescription:</label>
<textarea data-clear-btn="true" name="TechnicalDescription" id="TechnicalDescription" data-mini="true" data-inline="true" required="required" data-value="@Model.TechnicalDescription" placeholder = "Inserire qui la TechnicalDescription" rows="5" cols="40">@Model.TechnicalDescription</textarea>
</div>
<div class="ui-field-contain">
<label for="AttackScenario">AttackScenario:</label>
<textarea data-clear-btn="true" name="AttackScenario" id="AttackScenario" data-mini="true" data-inline="true" required="required" data-value="@Model.AttackScenario" placeholder = "Inserire qui l'AttackScenario" rows="5" cols="40">@Model.AttackScenario</textarea>
</div>
<div class="ui-field-contain">
<label for="Exploit">Exploit:</label>
<textarea data-clear-btn="true" name="Exploit" id="Exploit" data-mini="true" data-inline="true" required="required" data-value="@Model.Exploit" placeholder = "Inserire qui l'Exploit" rows="5" cols="40">@Model.Exploit</textarea>
</div>
<div class="ui-field-contain">
<label for="Credit">Credit:</label>
<textarea data-clear-btn="true" name="Credit" id="Credit" data-mini="true" data-inline="true" required="required" data-value="@Model.Credit" placeholder = "Inserire qui i Credit" rows="5" cols="40">@Model.Credit</textarea>
</div>
<div class="ui-field-contain">
<label for="URL">URL:</label>
<input type="url" id="URL" name="URL" value="@Model.URL" />
</div>
<div class="ui-field-contain">
<label for="AlertStatusId">AlertStatusId:</label>
<input type="number" id="AlertStatusId" name="AlertStatusId" min="0" max="10" step="1" value="@Model.AlertStatusId" />
</div>
<div class="ui-field-contain">
<label for="Type">Type:</label>
<input type="number" id="Type" name="AlertStatusId" min="0" step="1" value="@Model.Type" />
</div>
<div class="ui-field-contain">
<label for="DetailLevel">DetailLevel:</label>
<input type="number" id="DetailLevel" name="DetailLevel" min="-1" step="1" value="@Model.DetailLevel" />
</div>
<div class="ui-field-contain">
<label for="Language">Language:</label>
<input type="number" id="Language" name="Language" min="-1" step="1" value="@Model.Language" />
</div>
<div data-role="controlgrup" data-type="horizontal">
<a href="@Url.Action("Index", "Ticket")" class="ui-btn-inline ui-btn ui-corner-all ui-mini">Annulla</a>
<input type="submit" value="Salva" data-inline="true" data-mini="true" />
</div>
}
</div>
<!-- /tab-0 -->
答案 0 :(得分:0)
鉴于我们在评论中所做的测试,以下内容应解决问题:
@Html.TextBoxFor(mdl => mdl.test, new { @id="Test", @min="0", @max="10", @step="0.1" })