ASP.NET MVC下 同时使用onclick和href

同时使用onclick和href,根据先执行onclick根据onclick返回结果决定是否继续执行href的特性,onclick判断,href执行。

以下载为例:

function download_check(url, aid) {
    var f = false;
    $.ajax({
        async: false,
        cache: false,
        type: "GET",
        url: "/E_ModelManage/ModelAnalyse/QueryModulInfo?Model_Vsesion=" + Version + '&Model_Name=' + ModelName,//去controller中进行判断
        success: function (data) {
            if (data == "") {
               $("#lr-loadmodel").attr("href", "/E_ModelManage/ModelAnalyse/PageOfficeLoadExecl?Model_Vsesion=" + Version + '&Model_Name=' + ModelName + '&userID=' + userID);//对a标签href赋值
                f = true;
            } else {
                $.modalMsg(data, "error"); //页面提示
                f = false;
            }

        }
    });
    return f;
}

```csharp
 public ActionResult QueryModulInfo(string Model_Vsesion, string Model_Name)
    {
        Model_Name = HttpUtility.UrlDecode(Model_Name);
        if (!string.IsNullOrEmpty(Model_Vsesion) && !string.IsNullOrEmpty(Model_Name))
        {
            Model_Name = System.IO.Path.GetFileNameWithoutExtension(Model_Name);
            IEnumerable<E_A_MODELBASEINFOEntity> modelList = modelEmbedIBLL.GetModelByVersion(Model_Vsesion, System.IO.Path.GetFileNameWithoutExtension(Model_Name));
            DataTable DTModel = CommonClass.AsDataTable<E_A_MODELBASEINFOEntity>(modelList);
            if (DTModel.Rows.Count <= 0)
            {
                return Content("未查询到模型文件信息!");
            }
            string filePath = DTModel.Rows[0]["MODELPATH"].ToString();
            if (!System.IO.File.Exists(Server.MapPath(filePath)))
            {
                return Content("模型文件不存在!");
            }
        }
        return Content("");
    }
    public ActionResult PageOfficeLoadExecl(string Model_Vsesion, string Model_Name, string userID)
    {
        PageOffice.PageOfficeCtrl pc = new PageOffice.PageOfficeCtrl();
        //pc.AddCustomToolButton("保存", "Save()", 1);
        //pc.AddCustomToolButton("另存", "Save()", 2);
        //pc.SaveFilePage = "/ModelAnalyse/SaveDoc";                                //设置保存时访问的路径
        pc.ServerPage = "/pageoffice/server.aspx";                                  //pageoffice服务器页面
        string filePath = "";
        if (!string.IsNullOrEmpty(Model_Vsesion) && !string.IsNullOrEmpty(Model_Name))
        {
            Model_Name = System.IO.Path.GetFileNameWithoutExtension(Model_Name);
            DataTable DTModel = modelEmbedIBLL.GetModelByVersion(Model_Vsesion);
            if (DTModel.Rows.Count <= 0)
            {
                pc.WebCreateNew(userID, DocumentVersion.Excel2007);   //参数一:用户;参数二:文件类型
            }
            filePath = DTModel.Rows[0]["MODELPATH"].ToString();
            if (System.IO.File.Exists(Server.MapPath(filePath)))
            {
                //参数一:文档路径;参数二:文档打开模式;参数三:操作当前文档的用户名。一般来说,UserName 应该采用登录到您的Web应用程序的当前用户的名称
                pc.WebOpen(Server.MapPath(filePath), PageOffice.OpenModeType.xlsNormalEdit, userID);
            }
        }
        ViewBag.EditorHtml = pc.GetHtmlCode("PageOfficeCtrl1");
        ViewBag.Message = "模型加载成功";
        return PartialView();
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值