Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Behind the scenes
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Titre:
Behind the scenes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01560613
Message ID:
01560613
Vues:
74
Hi everybody,

I have the following Edit view:
@model CardNumbers.Objects.Client

@{
    ViewBag.Title = "Edit Client";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
}

        @Html.Partial("_ClientForm", Model)   

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script src="@Url.Content("~/Scripts/Clients.js")" type="text/javascript" ></script>
}
as you can see, it is supposed to use a different layout.

However, when I was tracing the execution in debugger I saw that the default _Layout view was hit before opening this view on this line
// GET: /Client/Edit/5

        public ActionResult Edit(int id)
        {
            var client = Db.GetClientById(id);
 
            return View(client);
        }
and also, more importantly, I am still struggling on trying to make the modal form work for the Edit button. With some help in stackoverflow I got the form show and be able to close and resize using this code:
var $dlg = $("#sform").dialog({
    autoOpen: false,
    show: "blind",
    closeOnEscape: true,
    resizable: true,
    width: 1200,
    height: 750,
    minHeight: 600,
    minWidth: 950
});

function RunModalDialog(title, url)
{
    
    if (title)
        $dlg.dialog("option", {"title": title });

    if (url)
       
        $dlg.load(url, function () {
            $dlg.dialog("option", {"title": title }).dialog("open");
        });
    else
      $dlg.dialog("open");
}

function add(com, grid){
    RunModalDialog("Create New Client");

    clearForm();
    $('#fntype').val('Add');
}
 
function edit(com, grid)
{
        $('.trSelected', grid).each(function () {
          
                var id = $(this).attr('id');
                id = id.substring(id.lastIndexOf('row') + 3);
                currentId = id;
                $('#fntype').val('Edit');
                var ClientName;
                ClientName =$('.trSelected td:eq(2)').text();
               var url = '/Client/Edit/' + id;            
            
               RunModalDialog("Edit Client: " + ClientName, url);
        });

    }
However, now, right after the Edit view finished loading, the Client method of the controller gets hit again (the Client is the main view which invokes that modal dialog). I am not sure why this is happening and how can I prevent it. It is not happening for the Add button.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform