Click here to Skip to main content
15,891,607 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Sending a collection of objects to the view in MVC Pin
Richard Deeming5-Feb-18 8:25
mveRichard Deeming5-Feb-18 8:25 
GeneralRe: Sending a collection of objects to the view in MVC Pin
Davstr5-Feb-18 18:24
Davstr5-Feb-18 18:24 
QuestionASP.Net MVC:clicking on routelink url not passing all the data to action Pin
Mou_kol5-Feb-18 3:50
Mou_kol5-Feb-18 3:50 
i have creating url using routelink.
C#
@Html.RouteLink("Edit", "PageWithId",
            new
            {
                controller = "Customers",
                action = "Edit",
                id = item.CustomerID,
                page = ViewBag.CurrentPage
            })


i am using this routing PageWithId with route link
C#
routes.MapRoute(
        name: "PageWithId",
        url: "{controller}/{action}/{page}/{id}",
        defaults: new { controller = "Customers", action = "Edit", page = UrlParameter.Optional, id = UrlParameter.Optional }
    );


i have 3 routing code in route.config file. here is all
C#
routes.MapRoute(
        name: "PageWithSort",
        url: "{controller}/{action}/{page}/{SortColumn}/{CurrentSort}",
        defaults: new { action = "Index", page = UrlParameter.Optional, SortColumn = UrlParameter.Optional, CurrentSort = UrlParameter.Optional }
    );

    routes.MapRoute(
        name: "PageWithId",
        url: "{controller}/{action}/{page}/{id}",
        defaults: new { controller = "Customers", action = "Edit", page = UrlParameter.Optional, id = UrlParameter.Optional }
    );

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );


when i run my program the route link generate url like http://localhost:55831/Customers/Edit/1/ALFKI

when i click on the link the Edit action is getting called but customer id is getting null where as ALFKI is there in url as customer id.

here is my edit action details
C#
public ActionResult Edit(string id, int page)
{
    if (id == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    Customer customer = db.Customers.Find(id);
    if (customer == null)
    {
        return HttpNotFound();
    }
    ViewBag.CurrentPage = page;
    return View(customer);
}


please tell me why id is getting null when ALFKI as passing as customer id?

thanks
AnswerRe: ASP.Net MVC:clicking on routelink url not passing all the data to action Pin
Richard Deeming5-Feb-18 8:17
mveRichard Deeming5-Feb-18 8:17 
GeneralRe: ASP.Net MVC:clicking on routelink url not passing all the data to action Pin
Mou_kol5-Feb-18 21:56
Mou_kol5-Feb-18 21:56 
QuestionHow to calculate page no for newly inserted records Pin
Mou_kol5-Feb-18 2:54
Mou_kol5-Feb-18 2:54 
AnswerRe: How to calculate page no for newly inserted records Pin
Maciej Los5-Feb-18 3:23
mveMaciej Los5-Feb-18 3:23 
Questionasp.net mvc routing with two controller reference Pin
Mou_kol5-Feb-18 1:18
Mou_kol5-Feb-18 1:18 
AnswerRe: asp.net mvc routing with two controller reference Pin
Richard Deeming5-Feb-18 8:09
mveRichard Deeming5-Feb-18 8:09 
GeneralRe: asp.net mvc routing with two controller reference Pin
Mou_kol5-Feb-18 21:54
Mou_kol5-Feb-18 21:54 
GeneralRe: asp.net mvc routing with two controller reference Pin
Richard Deeming6-Feb-18 2:11
mveRichard Deeming6-Feb-18 2:11 
GeneralRe: asp.net mvc routing with two controller reference Pin
Mou_kol6-Feb-18 2:38
Mou_kol6-Feb-18 2:38 
GeneralRe: asp.net mvc routing with two controller reference Pin
Richard Deeming6-Feb-18 2:50
mveRichard Deeming6-Feb-18 2:50 
QuestionWhat is Kubernetes and its usage Pin
Mou_kol4-Feb-18 22:11
Mou_kol4-Feb-18 22:11 
AnswerRe: What is Kubernetes and its usage Pin
Richard MacCutchan4-Feb-18 23:04
mveRichard MacCutchan4-Feb-18 23:04 
GeneralRe: What is Kubernetes and its usage Pin
Mou_kol5-Feb-18 0:36
Mou_kol5-Feb-18 0:36 
GeneralRe: What is Kubernetes and its usage Pin
Richard MacCutchan5-Feb-18 0:42
mveRichard MacCutchan5-Feb-18 0:42 
Questionwhat is needed to create a payment getway? Pin
Ayrton Yagami2-Feb-18 6:34
Ayrton Yagami2-Feb-18 6:34 
AnswerRe: what is needed to create a payment getway? Pin
OriginalGriff2-Feb-18 6:35
mveOriginalGriff2-Feb-18 6:35 
QuestionASP.Net MVC: Need guide line for a specific routing Pin
Mou_kol1-Feb-18 23:04
Mou_kol1-Feb-18 23:04 
AnswerRe: ASP.Net MVC: Need guide line for a specific routing Pin
F-ES Sitecore2-Feb-18 1:33
professionalF-ES Sitecore2-Feb-18 1:33 
GeneralRe: ASP.Net MVC: Need guide line for a specific routing Pin
Mou_kol4-Feb-18 8:10
Mou_kol4-Feb-18 8:10 
QuestionHow to create a popup when button clicked in parent form and display data grid view with selected columns data and with find and cancel buttons in popup and How to pass a selected value from popup window to parent form's TextBox? Pin
Member 113056081-Feb-18 6:22
Member 113056081-Feb-18 6:22 
AnswerRe: How to create a popup when button clicked in parent form and display data grid view with selected columns data and with find and cancel buttons in popup and How to pass a selected value from popup window to parent form's TextBox? Pin
Richard MacCutchan1-Feb-18 6:46
mveRichard MacCutchan1-Feb-18 6:46 
QuestionWhat type of db is stored in app_data folder of asp.net project Pin
Mou_kol1-Feb-18 1:51
Mou_kol1-Feb-18 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.