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
Similar Messages:
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
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
Jan 30, 2010
i don't want to use <input type="submit"> mainly because it's a button, i'd rather user ActionLink, so i am using Ajax.ActionLink, and i'm not sure what to place in the routeValues argument for it to pickup the new (edited) data (user enters comments etc) and send it to my action.
this is what i have, but of course, it sends the original comment before user edit back to the server/action
<%= Ajax.ActionLink("Update", "UpdateComment", Model.Comment,
New AjaxOptions With
{.UpdateTargetId = Model.CommentDivId, .HttpMethod = "Post"})%>
View 8 Replies
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
Mar 13, 2010
Getting to grips with ASP.NET MVC. So far, so good, but this one is a little nuts. I have a view model that contains a dictionary of attributes for a hyperlink, used like this:
menu = model variable Html.ActionLink(Html.Encode(menu.Name), Html.Encode(menu.Action), Html.Encode(menu.Controller), menu.Attributes, null) The problem is the position of "menu.Attributes" expects an object in the form:
new { Name = "Fred", Age=24 }
From what I can tell, this anonymous object is actually converted to a dictionary via reflection anyway BUT you can't pass a dictionary to it in the first place!!!
The Html generated for the link simply shows the dictionary type. How on earth do I get round this? The whole point is that its general and the controller can have set the menu.Attributes previously....
Based on a post below I tried the following:
Html.ActionLink(Html.Encode(menu.Name), Html.Encode(menu.Action), Html.Encode(menu.Controller), new RouteValueDictionary(menu.Attributes), new Dictionary<string,object>())
but this still doesn't work (I guess the code internally calls the generic method that takes objects?). The above (and my original solution of passing a dictionary to the 4th paramater produces a HTML similar to this:[URL] i.e. it's using reflection and working things out completely wrong...
View 4 Replies
Oct 9, 2010
how can i pass multiple parameters in html.actionlink?
View 1 Replies
Oct 5, 2010
How do I add a textbox for user input in the view and then change the link below to user the user input instead of the hard coded ID?
<%= Html.ActionLink("click me", "Index", new { id = 10057 } ) %>
View 3 Replies
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
Mar 28, 2010
In my view I have this:
[Code]....
action is:
[Code]....
But numbers is always null. How come? How can I get this to work?
View 4 Replies
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
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
Mar 1, 2010
I have created a VS 2008 web setup project with a dialog so that I can modify the web.config file at install. The setup worked as expected. However, I can not seem to accept a URL for a property value via custom data. I know directories are escaped with "", is there any similar escaping or tricks for a URL.
View 1 Replies
Jan 20, 2011
I have the following action executed when a user selects an item from the dropdown;
[Code]....
The object paymentApplicationRefund is populated. I want to get the contents of this object to put in a Html.Textbox(). How do I proceed??
View 11 Replies
Feb 24, 2011
My problem with the following is how do I send the ModelStateErrors to the action Employee, when I go through the catch part in DeleteEmployee
[Code].....
With return View("Employee", model); I a still not able to send the ID and Name as parameter.
View 5 Replies
Sep 6, 2010
I am having one controller Test having following actions
(1)public ActionResult ABC (string parameter1, string parameter2)
(2)public ActionResult XYZ (string parameter1, string parameter2,string parameter3, string parameter4)
i have added following html.routelinks
<%= Html.RouteLink("ABC","ABC", new { parameter1 = 100, parameter2 = 200 } )%><br />
<%= Html.RouteLink("XYZ", "XYZ", new { parameter1 = 1000 , parameter2 = 2000 }) %>
last two parameters in XYZ action are optionals so i have not passed them in Html.routelink
routes.MapRoute("ABC", "Test/{parameter1}/{parameter2}", new { controller = "Test", action = "ABC", parameter1= 0,parameter2=0 });
routes.MapRoute("XYZ", "Test/{parameter1}/{parameter2}/{parameter3}/{parameter4}", new { controller = "Test", action = "XYZ", parameter1=0,parameter2=0 ,parameter3=UrlParameter.Optional,parameter4=UrlParameter.Optional});
In above senario in both cases same route "ABC" is called eventhough i have clicked on second Html.routelink. can anyone solve this issue ? how can i route according to route name instead of number of parameters?
View 1 Replies
Jan 20, 2010
Is there any possibility to pass values of form elements to action methods but using parameters?I have a form with a lot of input fields and the method signature will get pretty long. Besides the form elements depend on each other so if the user makes a special choice only a subset of the form elements should be displayed so there are several combinationof values to be passed.Can I access the posted values in a generic way through a collection in the controller or something similar?
View 3 Replies
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
Sep 16, 2010
I am using ASP.NET MVC 1. I want to pass an int value to from an action to view. I can use 2 ways.
Use ViewData dictionary.
Define a class to contain the int value.
Other these two, Is there a way to pass the int value to view so that I can get the int value using just Model like
<label><%= Model %></label>
View 2 Replies
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
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
Dec 18, 2010
I have a text box on page load, loads a text value. I would like on the first instance of the page load for another textbox to equal to this value. As I have a gridview on the same page to update the textbox value does not get updated.
Essentially, if provide me with a VB script to obtain the value of the textbox on page load to pass to another textbox default value only on the same page.
View 4 Replies
Jul 1, 2010
i m using two grid in both gird i have a text box control on which i apply some java script funtion. my broblem is that when i press a tab key then its block my textbox. it means i m not able to press any key in that box even mouse click is not working.
my both grid in a same update panal but when i set focus out of that update panal and back to my text box they are start working properly.
i m applying a Web method on that text box also which call by javascript.3
View 2 Replies
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
Oct 15, 2010
I want to pass the 2 parameters to the action "Initialize" when my application launch.
[Code]....
Where my RegisterRoutes method looks like
[Code]....
View 1 Replies