值没有更新到MVC3视图的Jquery中的文本框

时间:2011-11-23 13:39:46

标签: jquery asp.net-mvc-3

我有这个观点

     @if (@Model.QuestionType == 5)
     {
      <div data-role="fieldcontain">
    @using (Html.BeginForm("SaveTextBox", "GetQuestion", Model))
    {
        @Html.AntiForgeryToken() 
        <fieldset data-role="controlgroup">
            <label for="select-choice-1" class="select">@Model.QuestionText
            </label>
            <br />
            @if (Model.Options != null)
            {
                foreach (var item in Model.Options)
                { 
                    <input type="text" id="textbox1" value="@item.OptionText" name="selectedObjects" />
                    <span id="username_warning" style="color: red"></span>  
                }
            }
            else
            {
                <input type="text" id="textbox1" name="selectedObjects" />
                <span id="username_warning" style="color: red"></span> 
            }
            <br />
            @if (Model.Validations != null)
            {
                <input type="hidden" id="hiddenvalidations" value="@Model.Validations" />
            }
        </fieldset>
        <p>
            <input type="submit" id="textboxsubmit" value="Next" />
        </p>
        }
</div>
}

我根据问题类型重定向到相同的视图。因此无论何时出现questiontype = 5,都会加载。

我正在阅读JQuery中的值

     $("#textboxsubmit").live("click", function () { 
        var textvalue = $("#textbox1").val(); 
        textvalue = jQuery.trim(textvalue);
        var validations = $("#hiddenvalidations").val();
    alert(textvalue);
    alert(validations);
   });

我正在阅读这些值并验证数据。

每次都给出第一个加载的文本框值。为什么它不在Jquery中更新。

关于直播的问题。我该如何解决?

1 个答案:

答案 0 :(得分:0)

你是说这个意思吗? text value = text value + jQuery.trim(text value);

相关问题