简体   繁体   English

为什么我不能使用带有的双数的JQuery输入标签。 相反,?

[英]Why I can't use JQuery input tag with double number that use . instead ,?

I am working on a C#/.NET web app that use JQuery to implement its view and I am finding some problems using double value into input tag. 我正在使用JQuery来实现其视图的C#/。NET Web应用程序上工作,并且在输入标记中使用双精度值时发现了一些问题。

For example I have the following code snippet into my view: 例如,我的视图中包含以下代码片段:

<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>

The value containet into the @Model.test model object field is 2.3 (I see it using the debugger) but into my input tag appear nothing. @ Model.test模型对象字段中的值containet是2.3 (我在调试器中看到了它),但是在我的输入标签中什么都没有出现。

I think that the problem could be related to the fact that JQuery use the comma to separate integer and decimal and instead it I have the . 我认为问题可能与JQuery使用逗号分隔整数和十进制,而我拥有的事实有关。 symbol. 符号。

Can you help me to resolve this issue? 您能帮我解决这个问题吗?

EDIT 1: This is my entire view 编辑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 -->

给定我们在注释中所做的测试,以下应该可以解决问题:

@Html.TextBoxFor(mdl => mdl.test, new { @id="Test", @min="0", @max="10", @step="0.1" })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在SharpDevelop上的这个小型C#程序中为什么不能使用“ float”而不是“ double”? - Why can't I use “float” instead of “double” in this small C# program on SharpDevelop? 为什么我不能在文本框占位符标记中使用帮助器? - Why I can't use helper in textbox placeholder tag? 为什么我不能使用数组的枚举器,而不是自己实现它? - Why can't I use the enumerator of an array, instead of implementing it myself? 为什么我不能在 input:name 中使用 @,后面有值 - why I can't use @ in input:name with value in the back 为什么我可以使用枚举作为 XAML 标记? - Why can I use an enum as a XAML tag? 什么时候应该使用double而不是decimal? - When should I use double instead of decimal? 为什么我不能只使用EventHandler <int> 而不是从EventArgs派生 - Why can't I just use EventHandler<int> instead of deriving from EventArgs 为什么 asp-for 输入标签助手总是使用表单数据而不是视图模型? - Why asp-for input tag helper always use form data instead of the viewmodel? 为什么我们不能在WCF中使用抽象类而不是接口? - Why can't we use abstract class instead of interface in WCF? 为什么我们不能使用 POST 而不是 GET 来获取数据? - Why can't we use POST instead of GET to fetch data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM