2016-11-01 5 views
-4

私はPromotionAdminコントローラを持っており、ユーザーからのデータを取得するためのビューを持っています。複数のフォームからデータを取得しようとしています。この1つのMVCで複数のViewModels 4 asp.netが期待どおりに動作しない

 <div class="col-md-9 well admin-content" id="spotpromotion"> 
      <div class="row setup-content" id="step-1"> 
        <div class="col-xs-8 col-md-offset-2"> 
         <div class="col-md-12"> 
          @using (Html.BeginForm("SpotPromotion", "PromotionAdmin", FormMethod.Post, new { @class = "form-group", enctype = "multipart/form-data", id = "SpotsubmitForm" })) 
          { 
           @Html.AntiForgeryToken() 
           <div class="form-group"> 
            <label class="control-label" for="idspchgpointtxt">Charge Point ID<span style="color: red">*</span> :</label> 
            <input class="form-control" name="spchgpointid" placeholder="Charge Point" id="spchgpointid" required="required"> 
           </div> 
           <div class="form-group"> 
            <label class="control-label col-sm-4" for="idspmessagetxt">Message<span style="color: red">*</span> :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label> 
            <textarea class="form-control" id="spmessage" placeholder="Message" name="spmessage" rows="5" ></textarea> 
           </div> 
           <div class="form-group"> 
            <label class="control-label col-sm-4" for="idspstarttimetxt">Start Time<span style="color: red">*</span> :</label> 
            <div class="row"> 
             <div class='col-sm-12'> 
              <div class="form-group"> 
               <div class='input-group date' id='datetimepicker1'> 
                <input class="date-picker form-control" placeholder="Start Time" id="spstarttimetxt" name="spstarttimetxt" /> 
                <span class="input-group-addon"> 
                 <span class="glyphicon glyphicon-calendar"></span> 
                </span> 
               </div> 
              </div> 
             </div> 
            </div> 
           </div> 
           <div class="form-group"> 
            <label class="control-label col-sm-4" for="idspstarttimetxt">End Time<span style="color: red">*</span> :</label> 
            <div class="row"> 
             <div class='col-sm-12'> 
              <div class="form-group"> 
               <div class='input-group date' id='datetimepicker1'> 
                <input class="date-picker form-control" placeholder="End Time" id="spendtimetxt" name="spendtimetxt" /> 
                <span class="input-group-addon"> 
                 <span class="glyphicon glyphicon-calendar"></span> 
                </span> 
               </div> 
              </div> 
             </div> 
            </div> 
           </div> 
           <div class="form-group"> 
            <label class="control-label col-sm-4" for="idsptargetcritxt">Target Criteria<span style="color: red">*</span> :</label> 
            <br /> 
           </div> 
           <div style="margin:30px;"> 
            <div class="form-group "> 
             <label class="control-label col-sm-4" for="idspstarttxt">Start</label> 
             <input type="radio" name="srptargetcriradio" id="spstartradio" onclick="document.getElementById('spvaluetxt').style.display = 'none';"> 
            </div> 
            <div class="form-group "> 
             <label class="control-label col-sm-4" for="idspchagingtxt">Chaging</label> 
             <input type="radio" name="srptargetcriradio" id="spchagingradio" onclick="document.getElementById('spvaluetxt').style.display = 'none';"> 
            </div> 
            <div class="form-group "> 
             <label class="control-label col-sm-4" for="idspendtxt">End</label> 
             <input type="radio" name="srptargetcriradio" id="spendradio" onclick="document.getElementById('spvaluetxt').style.display = 'none';"> 
            </div> 
            <div class="form-group"> 
             <label class="control-label col-sm-4" for="idsptargetcritxt">Value</label> 
             <input type="radio" name="srptargetcriradio" id="spvalueradio" onclick="document.getElementById('spvaluetxt').style.display = 'block';"> 
             <input type="number" min="0" class="form-control" placeholder="Value" id="spvaluetxt" name="spvaluetxt" required="required" style="display:none;" /> 
            </div> 
           </div> 
           <button class="btn btn-primary nextBtn btn-lg pull-right" name="spsubmit" id="spsubmit" type="button">Submit</button> 
          } 
         </div> 
        </div> 
      </div> 
    </div> 

    <div class="col-md-9 well admin-content" id="targetpromotion">   
      <div class="row setup-content" id="step-1"> 
       <div class="col-xs-8 col-md-offset-2"> 
        @using (Html.BeginForm("TargetPromotion", "PromotionAdmin", FormMethod.Post, new { @class = "form-group", enctype = "multipart/form-data", id = "TargetsubmitForm" })) 
        { 
         @Html.AntiForgeryToken() 
         <div class="col-md-12"> 
          <div class="form-group"> 
           <label class="control-label" for="idtpchgpointtxt">Charge Point ID<span style="color: red">*</span> :</label> 
           <input class="form-control" placeholder="Charge Point" id="tpchgpointid" name="tpchgpointid" required="required"> 
          </div> 
          <div class="form-group"> 
           <label class="control-label col-sm-4" for="idtpmessagetxt">Message<span style="color: red">*</span> :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label> 
           <textarea class="form-control" id="spmessage" placeholder="Message" name="tpmessage" rows="5" required="required"></textarea> 
          </div> 
          <div class="form-group"> 
           <label class="control-label col-sm-4" for="idtpstarttimetxt">Start Time<span style="color: red">*</span> :</label> 
           <div class="row"> 
            <div class='col-sm-12'> 
             <div class="form-group"> 
              <div class='input-group date' id='datetimepicker1'> 
               <input class="date-picker form-control" placeholder="Start Time" id="tpstarttimetxt" name="tpstarttimetxt" required="required" /> 
               <span class="input-group-addon"> 
                <span class="glyphicon glyphicon-calendar"></span> 
               </span> 
              </div> 
             </div> 
            </div> 
           </div> 
          </div> 
          <div class="form-group"> 
           <label class="control-label col-sm-4" for="idtpstarttimetxt">End Time<span style="color: red">*</span> :</label> 
           <div class="row"> 
            <div class='col-sm-12'> 
             <div class="form-group"> 
              <div class='input-group date' id='datetimepicker1'> 
               <input class="date-picker form-control" placeholder="End Time" id="tpendtimetxt" name="tpendtimetxt" required="required" /> 
               <span class="input-group-addon"> 
                <span class="glyphicon glyphicon-calendar"></span> 
               </span> 
              </div> 
             </div> 
            </div> 
           </div> 
          </div> 
          <div class="form-group"> 
           <label class="control-label col-sm-4" for="idtptargetcritxt">Target Criteria<span style="color: red">*</span> :</label> 
           <br /> 
          </div> 
          <div style="margin:30px;"> 
           <div class="form-group "> 
            <label class="control-label col-sm-4" for="idtpstarttxt">Start</label> 
            <input type="radio" name="srptargetcriradio" id="tpstartradio" onclick="document.getElementById('tpvaluetxt').style.display = 'none';"> 
           </div> 
           <div class="form-group "> 
            <label class="control-label col-sm-4" for="idtpchagingtxt">Chaging</label> 
            <input type="radio" name="srptargetcriradio" id="tpchagingradio" onclick="document.getElementById('tpvaluetxt').style.display = 'none';"> 
           </div> 
           <div class="form-group "> 
            <label class="control-label col-sm-4" for="idtpendtxt">End</label> 
            <input type="radio" name="srptargetcriradio" id="tpendradio" onclick="document.getElementById('tpvaluetxt').style.display = 'none';"> 
           </div> 
           <div class="form-group"> 
            <label class="control-label col-sm-4" for="idtpptargetcritxt">Value</label> 
            <input type="radio" name="srptargetcriradio" id="tpvalueradio" onclick="document.getElementById('tpvaluetxt').style.display = 'block';"> 
            <input type="number" min="0" class="form-control" placeholder="Value" id="tpvaluetxt" name="tpvaluetxt" required="required" style="display:none;" /> 
           </div> 
          </div> 
          <button class="btn btn-primary nextBtn btn-lg pull-right" name="tpsubmit" type="button">Submit</button> 
         </div> 
        } 
       </div> 
      </div> 
    </div> 

ように私はPromotionAdminコントローラー、私は二つの方法

[CustomAuthorize(Roles = "admin")] 
[HttpPost] 
public ActionResult SpotPromotion(string spchgpointid, string spmessage, string spstarttimetxt, string spendtimetxt, string spstartradio, string spchagingradio, string spendradio, string spvalueradio) 
{ 
      string filename = "5fa9d4e9-c2ee-4d34-8d83-a83a60ffa49d.xls"; 
      string couponfrom = "zcc"; 
      List<ChgPoint> ch = new List<ChgPoint>(); 
      ch = SpotControllerCRUD.GetAllChagePoint(); 
      return View("Index"); 
} 

[CustomAuthorize(Roles = "admin")] 
[HttpPost] 
public ActionResult TragetPromotion(string tpchgpointid, string tpmessage, string tpstarttimetxt, string tpendtimetxt, string tpstartradio, string tpchagingradio, string tpendradio, string tpvalueradio) 
{ 
      string filename = "5fa9d4e9-c2ee-4d34-8d83-a83a60ffa49d.xls"; 
      string couponfrom = "zcc"; 
      List<ChgPoint> ch = new List<ChgPoint>(); 
      ch = SpotControllerCRUD.GetAllChagePoint(); 
      return View("Index"); 
} 

が、押しボタンを提出するとき、それはアクションメソッド

+0

あなたの質問は何ですか?アクションパラメータはnullですか? – CodeNotFound

+0

「送信ボタンを押してもアクションメソッドには行きませんでした」詳細を追加 – nu123

+0

''が必要なフォームを送信するには、送信ボタンとしてボタンを変更します。 –

答えて

1

変更に行ってきましたしませんでした次呼んでいるが呼んでいますボタンの代わりにtype = "submit"を入力してください。

typebuttonの場合は、その操作を指定する必要があります。

+0

それは私のミス.. – nu123

関連する問題