0

I would like to pass parameter grid-page, but i get error while compiling

Error 2 Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

return RedirectToAction("Grid", new { sukurta = item.lic_plate, grid-page = 2 });

tereško
  • 58,060
  • 25
  • 98
  • 150
user964960
  • 35
  • 1
  • 9
  • Use `grid_page`. Identifiers can't contain a hyphen. – CodeCaster Jul 11 '14 at 11:24
  • 1
    A `-` is not a valid character for a variable name. – user247702 Jul 11 '14 at 11:24
  • @Stijn Might as well post that as an answer since it's... the answer. – Ant P Jul 11 '14 at 11:25
  • @AntP I think the question should be closed as a typo instead. Feel free to post an answer though if think it should stay open, I don't mind :) – user247702 Jul 11 '14 at 11:27
  • @Stijn I'm not so sure - in this instance it's a typo, but the same situation could easily arise as a genuine "what does this error mean," scenario, so it's probably worth keeping (with a better title). – Ant P Jul 11 '14 at 11:41
  • @AntP I just found a [possible duplicate](http://stackoverflow.com/questions/9196776/invalid-anonymous-type-member-declarator-anonymous-type-members-must-be-declare), it's for `ActionLink` but it's the same principle. I can't vote again to close, what do you think? – user247702 Jul 11 '14 at 11:44

1 Answers1

0
Check this code
---------------
My simple suggestion is just remove '-' symbol
public ActionResult Index()
            {

                  return RedirectToAction("About" , new
                  {
                        sukurta = "a" ,
                        grid_page = "3"
                  });
            }

            public ActionResult About( string sukurta , string grid_page )
            {


                  return View();
            }
ARUNRAJ
  • 469
  • 6
  • 15