您的当前位置:首页正文

C#页面跳转的几种方式

来源:华拓网

C#页面跳转的几种方式

方式一

html中不带参数跳转:
带参数跳转:

<div class="A_area">
    <a href="@Url.Action("CX", "YWCX")" class="A_button">大陆居民</a>
     <a href="@Url.Action("CX1", "YWCX", new { id = "GAT" })" class="A_button">港澳台居民</a>
    <a href="@Url.Action("CX1", "YWCX", new { id = "WGR" })" class="A_button">外国人</a>
</div>
方式二

js控制页面跳转
带参数和不带参数

<div>
 <div class="btn" onclick="dosubmit('@ViewBag.ID','@ViewBag.Name')">下一步</div>
</div>
<script type="text/javascript">
    function dosubmit(id, mc) {
        if (id != "" && mc != "") {
            location.href = '@Url.Action("Appointment", "home")/' + id + "?text=" + mc;
       } else {
            location.href = "@Url.Action("Appointment", "home")";
        }
    }
</script>
方式三

使用ajax进行页面跳转

  ajaxSubmit('@Url.Action("GetVertifyCode", "Plan")', { sfzh: IDstring, zjlx: ZJLXstring }, "", function (data) {
                if (data.Result) {                        
                    noticeshow();
                }
                else {
                    $("#error").show();
                    alert("未查询到结果");
                }
            });

封装的页面跳转方法

function ajaxSubmit(url, data, msg, callback) {
try {
    if (APP_TOKEN != "" && APP_USERID != "") {
        if (data == null)
            data = {};
        data["app_token"] = APP_TOKEN;
        data["app_userid"] = APP_USERID;
    }
}
catch (e) {

}

$.ajax({
    type: 'POST',
    url: url,
    data: data,
    datatype: 'json',
  
    success: function (re) {
        if (msg != "NO_MSG")
            hidenLoading();

        if (typeof callback != "undefined") {
            callback(re);
        }
    },
    error: function (e) {
        if (msg != "NO_MSG")
            hidenLoading();

        if (e.statusText == "timeout") {
            //alert("网络超时。");
            if (msg == "NO_TIMEOUT_MSG") {
                callback("TIMEOUT");
            }
            else {
                messagebox({
                    title: "提示",
                    button: "ok",
                    text: "网络超时请重试"
                });
            }
        }
    },
    complete: function () {
    }
});

}

方式四