Html.actionlink Doesn't Pass Parameter To Controller Action

May 12, 2010

m having problem in passing parameter to controller action, i have done the following

Url.Action("SchoolDetails","School",new{id=item.SchoolId}) and my controller action follows

public ActionResult SchoolDetails(string schoolId,_ASI_School schoolDetail)
{
schoolDetail = SchoolRepository.GetSchoolById(schoolId);
return View(schoolDetail);
}

i dn't know why the schoolId above in action is getting null..

View 1 Replies


Similar Messages:

MVC :: How To Pass Textbox Value To Action Via ActionLink

Jun 24, 2010

Having a brain fart again - i just wanna pass the contents of a TextBox to a Controller Action via an ActionLink - and i cant figure out how

Heres my View

[Code]....

My Controller:

[Code]....

but name is always null - how can i pass the current value in the textbox? ViewData directionary doesnt seem to work either

PS. Id love to pass the entire model from the View -> Controller - but it complains about not having a parameterless constructor (which i do)

View 5 Replies

MVC :: Cannot Pass Model To Action Via ActionLink?

Jun 4, 2010

I'm trying to implement paging in my app, so i need to know what page the user wants to click on, as well as pass the model (for some fields)I'm able to pass the desired page, just not the model (for the search criteria)here is my view:

[Code]....

Heres my Controller Action

[Code]....

My ViewModel SearchResults has a string property "Search". When i do it this way searchModel == null in the NextPage Action.

View 2 Replies

MVC :: Display Html.Actionlink Through Controller?

Oct 16, 2010

I am trying to display Html.Actionlink through controller(MVC). Here is the example what am trying to do...

public string test(){
string testString = "<%: html.ActionLink('click', 'test', new AjaxOptions() { UpdateTargetId = 'test' }) %>";
return testString;
}

i want to display testString in view. but am not getting the actionlink in view..i can display anchors which is given below:-

public string test(){
string testString = "<a href ="test"> click here</a>";
return testString;
}

View 3 Replies

MVC :: Pass Parameter From Controller To View And Back To Another Controller?

Aug 16, 2010

I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.

My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)

Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.

My Gift List controller knows the PersonID I want to pass but the view doesn't.

How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?

View 2 Replies

Make Mvc Configurable Html.ActionLink Controller / Method

May 7, 2010

I have ascx partial view with html-layout like that

<%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, ... )) %>

My ascx is pretty big & I'd like to reuse it, changing controller/method in Html.ActionLink with another controller/method. Method of another controller has the same signature as PersonController.Publications. Whats best way how to make controller/method configurable for my layout.

View 1 Replies

MVC :: Html.ActionLink Parameter Order

May 25, 2010

I've never been able to understand why it is that some things are made in a particular way, and Html.ActionLink is one of these. In Global.asax, if I want to create a route, it has the format:

[Code]....

The order of the necessary parameters here is "name/controller/action/extra params". When using Html.ActionLink, the parameter order is "name/action/controller/extra params", which is much the same but with two of them switched around. To make things more confusing, the rendered html from the Html.ActionLink has the original order "controller/action/extra params" with the name inside of the anchor tag. Why do this? It's easy enough to memorize that the order is switched for absolutely no reason I can discerne, but why do it in the first place?

View 8 Replies

How To Pass JavaScript Function As A Parameter In The Route Values Of Ajax Actionlink

Apr 20, 2010

I need to pass javascript function as a parameter value to the ajax actionlink in asp.net mvc app. how can we achieve this?

View 1 Replies

MVC :: Pass A String Value To A Controller Action?

Feb 16, 2011

I am trying to get this functionality on my jokes website:

www.mysite.com/category/bar

To get all the bar jokes ..etc

The way I have my route right now is:

{controller}/{action}/{id}

which means I have to type:

www.mysite.com/category/index/bar

the problem is that even with that, the string parameter "bar" isn't being acknowledged ! ( I know from debugging). Here is my Index action in the Category controller:

[Code]....

View 8 Replies

How To Pass JSON To Controller Action

Mar 6, 2011

I have some textboxes and a table of data created client side that I want pass to a controller as JSON.

I want to use Jquery to enumerate the table.

Assume I have 2 textboxes called name and age. Assume a table with 2 columns. one column with class called phonetype and one column class called phonenumber.

So how do construct the JSON from this?

View 1 Replies

MVC :: Pass ID Value To Home Controller Index Action?

Dec 31, 2010

My query is somehow related to passing the id values as parameters in MapRoute on RegisteredRoute method

routes.MapRoute("MachineGroupList:, PhysicalMachine/ListGroupMachine/{used}/Page/{page}", new {controller="PhysicalMachine", action="ListGroupMachine",id="XNA"});

How can i use {used} value in id ?

My Page have:

<%: Html.RouteLink("<<<", "MachineGroupList", new{used=Model.UsedBy,page=(Model.PageIndex-1),id=Model.UsedBy})%>

My controller for this Action is:

public ActionResult ListGroupMachine(string id, int page=0)
{
....
}

Everytime I call this Action the Id should be of groupBy column; over here it is 'Used' First time I have called this Action from <%html.ActionLink("Machine","ListGroupMachine", new {id=Model.UsedBy})%> But in my Html.RouteLink the id object is not identified in MapRoute method...

View 2 Replies

How To Pass Parameters To An Action Using Html.Action() In MVC?

Jun 30, 2010

I've been using Html.Action("ActionName", "ControllerName") to invoke child actions across controllers without needing to have the view in ViewsShared. This has been working great for displaying things like session or cookie information.

Instead of just accessing cookies, I would like to pass additional parameters to Html.Action("ActionName", "ControllerName") so the action can execute different code based on the the data passed to the original view.

Should I be using a different method to pass parameters to a child action in a different controller?

View 1 Replies

MVC :: Pass ID Value To Home Controller Index Action? (like Www.test.com/23)

Jun 18, 2010

I want to have the following URL pattern in my MVC application:

www.test.com -> display welcome page

www.test.com/5 -> display article with ID 5

I have set up my Home Controller like this:

[Code]....

When I request www.test.com, everything works as expected (the Index action is invoked with the ID parameter set to NULL).

But when I request www.test.com/5 it says: HTTP 404 Resource not found. When I request www.test.com/?id=5 it works.

View 2 Replies

MVC :: Pass Multiple Parameters In Html.actionlink?

Oct 9, 2010

how can i pass multiple parameters in html.actionlink?

View 1 Replies

C# - How To Html.ActionLink And HTML As Parameter

Jul 31, 2010

Html.ActionLink("<span class="title">Retry</span><span class="arrow"></span>", "Login", "User")

If I execute above code in ASP.Net MVC 2, I get the following output on my screen:

How do I disable the escaping of the code, so my span is within the ActionLink, and not displayed as output?

I know this is expected behavior, to keep it safe, but I want it to interpret the HTML code I pass as a parameter.

View 4 Replies

Javascript - How To Pass Json Collection Object To Mvc Controller Action Method

Dec 21, 2010

I am creating one Json array object and trying to pass it in MVC controller action method but i am getting null paramerter; as per my knowledge json only maps .net primitive datatypes.... so it assign null value.

Note: when i have look at request object i found that there are three parameter of created array. But how to get that value as parameter of function?

View 2 Replies

MVC :: Trying To Pass A Parameter From A View To Another Controller

Apr 18, 2010

i have a view /categoria/index

[Code]....

i am trying to call the action from /imovel/index

with an id

but the thing is that i am getting null

[Code]....

View 2 Replies

MVC :: HTML Submit Button - How To Call Controller Action

Aug 12, 2010

In the view I have a HTML button:

<input type="submit" value="Submit" />

Also I have a dropdownlist, how do I call the controller's action after I click the "Submit" button?

And how do I pass the Model back to the controller action as well?

The reason I want to pass back the model (or other object/class) to controller's action is I might have 5 dropdown lists and 3 edit boxes values to be sent as parameters. So I would like to assign these parameters into a object and send it back to controller's action.

View 11 Replies

MVC :: Getting Values In Html Table To A Controller Action Method?

May 11, 2010

I have an editable table in my view.

how can i accept the whole table in a controller action method?

what parameter should i gave to accept the whole table

View 1 Replies

MVC :: Return Text Stream Of HTML From Controller Action?

Nov 6, 2010

How does a controller action return an HTML stream as the View? ( in place of the name of the View file )

I want to return a simple "error detected" or "action completed" page to the browser. And I dont want to clutter up my project with yet another view. The return string being "<html><body><h1>Error. Customer xxxx is not found</h1></body></html>"

( thinking about it, better to have a general purpose view in a folder named "Common". Then pass the message text in ViewData. Still curious to know how to return an html stream. )

View 1 Replies

MVC :: How To Call Action In Controller On Input Submit In HTML Page

Jul 13, 2010

I am quite new to MVC development and facing some basic issues.

I am having a form on which I am taking input form user. It is bould to one of the properties on Model class.

I am having a submit button

<input type="submit" value="Save"/>

Now I want to call Save Action in my controller on click on this Save button.

But it is not working. I have checked on following things:

1. My HTML page is correctly point to the controller

2. I have written HTML code as

<%= HTML.BeginForm("Save","ControllerName", FormMethod.Post); %>
<input type="submit" value="Save"/>
<%= HTML.EndForm();%>

View 5 Replies

MVC :: How To Pass Html.TextBox To Controller

Jan 14, 2010

I've a controller with different actions that calls the DB code and return result. I want to pass the value of text box to different actions in controller.

How to do it? I know that, I can pass values by using form. But, I don't to know how to call different actions in controller from single view.

View 8 Replies

How To Pass Html Table Data To Controller In Mvc2.0

Dec 15, 2010

I have a HTML table (grid). I want to pass the html table data to controller.(mvc 2.0)

View 2 Replies

MVC :: Pass Item_Id Parameter Into "Edit Action" To Update?

Mar 28, 2011

I have code Controller :

[Code]....

I use Viewer :

[Code]....

how i can pass Item_Id parameter into "Edit Action" to update?

View 4 Replies

How To Set The Master Page's Html Title From Within A Controller's Action Or View Page

Mar 10, 2010

I have a controller's action and view page that uses a master page.

The master page has the html title section like:

<title>this is the page's title</html>

How can I access this section from within my controller's action (preferably) or my action's view page?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved