目前分類:ASP.NET MVC (5)

瀏覽方式: 標題列表 簡短摘要

使用Ajax.BeginForm需要載入下面兩個才能實現部份更新...,否則會以整頁刷新,弄了好久

@Scripts.Render("~/bundles/jquery")

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

依序按Alt + B + R,即可實現重建(Rebuild)

原本一直尋找是否有可同時按的快速鍵,卻忽略了還有依序按的快速鍵, 所以一直以來都是直接使用滑鼠

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

使用反射(Reflection)來載入指定Action的Model,再傳入到指定的View,

會這麼做的原因是因為action並不是固定的,使用反射來取得Model,再對Action的View傳入,來達成不改變網址的情況下顯示別的View!

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

未命名

 

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

///
/// 檢查特定Controller和Action是否存在
///
///控制器名稱
///動作名稱
/// 
public static bool IsControllerAndActionExist(string controller, string action)
{
    var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
    Type[] types = executingAssembly.GetTypes();
    Type type = types.Where(t => t.Name == controller + "Controller").SingleOrDefault();
    if (type != null && type.GetMethod(action) != null)
    {
        return true;
    }

    return false;
}

資料來源:http://stackoverflow.com/questions/7033428/how-to-make-sure-controller-and-action-exists-before-doing-redirect-asp-net-mvc


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