ASP.NET MVC and passing ID to strongly typed BeginForm -


I have some problems passing an ID from the URL in my controller action

Say I have This is URL: Bing / Index / 4

In my master page, I would like to generate a form which will be the Bing Controller Search Action

How to get the ID (4 In the example) to pass it to the url search operation?

Thank you for your help

To access that data in a master page For, your controllers will need to add it to ViewData so that the master page should be used.

  Public Performance Index (String ID) {ViewData ["SearchID"] = ID; See Return (); }  

Then in your master page, you can see it using ViewData

  (HTML.BeginForm ("Search", "Bing", { ID = Vendetta ["SearchInnd"]})  

For a strongly typed view, I have a unsmoded square that has a property that needs a master page and all my models Base class public square model model {prop string search id {get; set;}} Public class home index model: basemodel {} public functioning index (String ID) {Homeindex Model Model = New

Your master page will look like this:

  & lt;% @ Master language = "C # "Initix =" System.web.mvc.ViewMasterPage using the        Search (Model.SearchID))) {%>  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -