Action方法上的FormCollection输入具有空值

时间:2017-08-27 14:14:24

标签: asp.net-mvc

我试图在动作方法上获取表单输入的值。

MVC查看

   var start = elem[0].selectionStart;
   if(start == 1 && event.currentTarget.value.charAt(start-1)==" "){
   var value = event.currentTarget.value.trim();
   event.currentTarget.value = value;
   setTimeout(() => elem[0].setSelectionRange(0, 0),0);
}

家庭控制器的操作方法

 @using (Html.BeginForm("Report", "Home"))
                   {
                        <div class="common_input Volunteer_input">
                            <div class="row">
                                <div class="col-sm-12">
                                    <label for="firstName">Reporter:</label>

                                    <div class="select_option_one">
                                        <input type="text" id="ReporterCountries" class="ct-select2 ReporterCountriesList" />

                                    </div>
                                </div>

                            </div>

                            <div class="row">
                                <div class="col-sm-12">
                                    <label for="firstName">Partner:</label>
                                    <div class="select_option_one">
                                        <input type="text" name="PartnersCountries" id="PartnersCountries"  class="ct-select2 CountryList" />
                                    </div>
                                </div>
                            </div> 
                            <h3>Comparators</h3>
                            <div class="row">
                                <div class="col-sm-12">
                                    <label for="firstName">Partner:</label>
                                    <div class="select_option_one">
                                        <input type="text" name="CompareCountryList" id="CompareCountryList" class="ct-select2 CountryList" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-sm-12">
                                    <label for="firstName">Rank Growth:</label>
                                    <div class="select_option_one">
                                        <input type="text" name="RankGrowth" id="RankGrowth" class="ct-select2 RankGrowth" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="sub_submit">
                                        <button type="submit" class="common_btn hvr-sweep-to-bottom">View<i class="fa fa-long-arrow-right"></i></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                   }

当我尝试检索动作控制器上的输入值时,我正在接收视图上的所有控件,但值将变为空。

0 个答案:

没有答案