关于ajax动作链接 [英] about ajax action link

查看:159
本文介绍了关于ajax动作链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似下面的ajax动作链接按钮

i have a ajax action link button like below

@Ajax.ActionLink("View Document", "ViewDocument","Property",
                          new RouteValueDictionary { { "id", ViewBag.DocumentName } },
                new AjaxOptions{
                    HttpMethod="GET",
                    InsertionMode=InsertionMode.Replace,
                    LoadingElementId="loading",
                    UpdateTargetId = "View"
                })





当我点击此链接时,我想重定向到带有链接ID的部分视图,并通过使用这个id我发现图像文件名如



whe i click on this link i want redirect to partial view with id of the link and there by using this id i am finding image file name like

public ActionResult ViewDocument(int id)
        {
            try
            {
                var document = db.Documents.Where(d => d.Id == id).FirstOrDefault();
                var documentFilename = document.FileName;
                ViewBag.Document = string.Format("~/App_Data/Uploads/{0}.jpg", documentFilename);
                return PartialView();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }





在局部视图中我有图像控制绑定文件,我在部分视图上方找到视图是

@model MVC5Application.Models.Property



< img src =@ ViewBag.Documentalt =/> ;

我在点击ajax链接时使用jquery



in partial view i have image control to bind file which i have found above the partial view is
@model MVC5Application.Models.Property

<img src="@ViewBag.Document" alt="" />
and am using jquery on click of ajax link

$(function () {
           $(document).dialog({
               autoOpen: false,
               width: 1500,
               resizable: false,
               modal: true
           });
       });

       $(document).ready(function() {
           $('#View Document').click(function () {
               $(document).load("@Url.Action("@ViewBag.Document")", function () {
                   $(document).dialog('open');
               });

               return false;
           });
       });









但它没有重定向局部视图。



任何人都可以帮我解决问题。





but it is not redirecting partial view.

Can any one help me out tachieve the same.

推荐答案

(function() {
(function () {


(document).dialog({
autoOpen: false
宽度: 1500
可调整大小: false
modal: true
});
});
(document).dialog({ autoOpen: false, width: 1500, resizable: false, modal: true }); });


(document).ready(function(){
(document).ready(function() {


这篇关于关于ajax动作链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆