好久沒回來了...不過最近又碰到以後一定會忘記的問題

在製作志工後台網頁時

發現需一張view裡需要兩個submit btn

 

搜尋條件=> 搜尋btn

表單清單=>修改送出btn

 

找資料先參考了此網頁方法二

http://www.cnblogs.com/wuchang/archive/2010/01/29/1658916.html

 

將View 修改btn如下

<td><input type="submit" name="action" value="搜尋"  /></td>

<td><input type="submit" name="action" value="送出"  /></td>

 

然後Controller接值的時候用if判斷Value

 

 

public ActionResult Index(string action,string status,CheckViewModel checkvm)

        {

                If (action==”搜尋”){

                …..

}

else if(action==”送出”){

…..

}

 

 

結論是可以接的到值且依Action判斷後執行code,But!!!

因為ActionResult裡有收到Chckvm的關係,所以導致搜尋條件時,Checkbox不會依據最新的條件去顯示(因為一值拿舊的)

 

=====================解法=============================

喬治哥看了我的code後,建議我將view分成兩個BeginForm,然後在BeginForm中指定傳回的Action即可解決問題

@using (Html.BeginForm("Index","Home")){}

 

 

以上~ End

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JayeChen987 的頭像
    JayeChen987

    Jaye的碎碎念

    JayeChen987 發表在 痞客邦 留言(0) 人氣()