1

I've got a view that defines a form as

<% using (Html.BeginForm( "Update", "CcisCase", FormMethod.Post, new { id = "ccisEditForm" } ))

with a submit button:

In the RegisterRoutes method (in the HttpApplication-derived class in global.asax.cs), I've got:

            routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" );

        routes.MapRoute(
            "CcisCase",
            "CcisCase/{action}/{cmDatabaseId}/{caseId}",
            new { Controller = "CcisCase", Action = "CcisCaseEdit", caseId = "" } );

The url generated by MVC ends with "/Update" but there are no parameters. What am I doing wrong?

Thanks, Bob

3 Answers 3

2

What parameters are you expecting to see? A post does not append parameters to the querystring, a FormMethod.Get would. And, that overload with the id is the collection of HTML attributes to render for the tag (which I'm assuming you knew, but just in case).

HTH.

Sign up to request clarification or add additional context in comments.

Comments

1

Your route contains a parameter {caseId} but your BeginForm only defines an id value.

new {id = "cssEditForm"}

You need something like this to include the caseId value

using (Html.BeginForm( "Update", "CcisCase", FormMethod.Post, new { caseId = 1, id = "ccisEditForm" }

If your action isn't using the id="ccisEditForm" value then you can remove that for less code clutter.

1 Comment

Thanks. I just posted my fix, and had to use both the strongly-typed RouteValueDictionary and Dictionary parameters (see my answer later).
1

I figured out what my problem was. I had to pass the existing route data as follows:

        using (Html.BeginForm( "Update", "CcisCase", ViewContext.RouteData.Values, FormMethod.Post, new Dictionary<string, object> { { "id", "ccisEditForm" } } ))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.