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
Similar Messages:
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
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
Feb 13, 2011
I want to pass a message from the controller to a view using Viewdata. Here is my code:
public ActionResult Create(FormCollection createPage)
{
try
{
......................
ViewData["Message"] = "Success - rec added!!!!" ;
return RedirectToAction("Index");
}
catch (Exception e)
{
ViewData["Message"] = "Exception: " + e.ToString();
return RedirectToAction("Index");
}
On my View I have:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>::><%: ViewData["Message"] %><::</h2>
<h3>==><%= ViewData["Message"] %><==</h3>
<p>
This is Index.aspx page in Controller folder
</p>
</asp:Content>
I am getting result with empty ViewData["Message"]
View 4 Replies
May 25, 2010
My view has a number of rows.
Each row has a drop down, a text box and an "add" link. I'd like for someone to select something in the drop down, edit something in the text box and pass that information to an Action in the Controller.
I know i can do something like this:
[Code]....
[Code]....
Which is kind of gross - id like to do just call one action, that passes the selected drop down value, the textbox value and call just the one action, is it possible to do something like this:
[Code]....
Where i pass the Dropdownlist selection and the textbox value to my controller specifically
View 3 Replies
Jan 16, 2011
In asp.net mvc3, I've got a few local variables in one of the controller, is there any neat way to pass all these variables to view? Something like "locals()" in python?
View 1 Replies
Jun 15, 2010
[Code]....
for List<AnswerInfo>,
[Code]....
now, what i want to do is to place few textboxes on a view that allow users to input the Answer Text. after click the submit button. i want List<AnswerInfo> which contains the Text information pass to the controller. can anyone tell me how to do it?
View 4 Replies
Oct 8, 2010
How Can I Pass data(not the part of model) to Controller from View? View Code
[Code]....
View 4 Replies
Mar 24, 2011
I am Francesco and I am newbie. I have a problem with ASP.NET MVC3 regarding the data posted between View and Controller. My goal is to use a form to edit a specific record from my database and then post it back to the controller, which is in charge of checking the record's fields and submit them into the database.
The data are passed from the Controller to the View by using a ViewModel and therefore the DefaultDataBinding does not apply in this case. I tried many approaches, I monitored the communication with Fiddler but I couldn't solve my problem. The method described by Phil Haack does not work and neither does the FormCollection.
Here you have the code:
ViewModels: I pass it to the View to create a table. Name and the list of Item names (table columns headers) are just to be displayed. I want to have back the Id, the Month (they are passed correctly as parameters and represents table row headers) and most important the ActualValue of the Items and their Id (I have an association table in my database with Id, Itemid and Month as keys)
[Code]....
View: The View is strongly typed as ViewModels.EditViewModel and sends the fields through a submit button. I have to generate a table by using foreach loops, because I do not know how many items there are in advance
Controller: The controller has to update each kpi passed from the view related to a specific Id and Month.
[HttpPost]
public ActionResult EditMonth(int Id, int Month, //FormCollection kpiValues)
View 1 Replies
Dec 24, 2010
My way to ASP.NET MVC was not across ASP.NET Web Forms, so it's hard for me to understand how better to pass value from ASP.NET MVC controller to ASP.NET webforms script which is inside MVC View.
For example, controller action:
[Code]....
How to assign a value of myvar from a controller action to par1 variable in the View instead "stubvalue"?
View 3 Replies
Mar 24, 2010
Well i am a sort of a beginner..
I am writing an Application using mvc and c#..
Well i have a View where i have the following code..
[Code]....
View 1 Replies
Jun 17, 2010
if I use a Html.Hidden field in my view, when the value click to submit the form I would like to pass this data to the controller. This variable would contain int as key and string as value,
Dictionary<int, string> interestTable = new Dictionary<int, string>();
How can I specify the htmlAttribute fo this variable in my Html.Hidden code?
<% using(Html.BeginForm("Search", "SearchMembers")) { %>
<input type="hidden" name="ResearchInterests" id="researchInterests" value=""/>
<%= Html.Hidden("fullInterestsPath") %>,
View 5 Replies
Jul 12, 2010
Can a view pass some sort of model like data to a Master page? I am using the ViewData collection, but that makes for confusion in my code. When I specify the Master in the View, can I also specify a parameter?
View 1 Replies
Apr 15, 2014
how can we pass data from view to controller in Asp.net mvc
View 1 Replies
Jan 27, 2010
Can i create a partial view and a controller that will feed data to the view, and if i render that partial in a Master page, the Data will show on whatever URL i am?
Or is there another way of showing content from database on every page(view)?
View 2 Replies
Aug 6, 2010
I've got problem with my app .
I've got such classes (this is some kind of tree structure):
[Code]....
[Code]....
in Index() action i've got this piece of code
[Code]....
[Code]....
View 2 Replies
Oct 5, 2010
I have the following scenario: my website displays articles (inputted by an admin. like a blog).So to view an article, the user is referred to Home/Articles/{article ID}.However, the user selects which article to view from within the Articles.aspx view itself, using a jsTree list.So I what I need to do is to be able to differentiate between two cases: the user is accessing a specific article, or he is simply trying to access the "main" articles page. I tried setting the "Articles" controller parameter as optional (int? id), but then I am having problems "using" the id value inside the controller.
View 7 Replies
Apr 3, 2010
In my application I have a string parameter called "shop" that is required in all controllers, but it needs to be transformed using code like this:
shop = shop.Replace("-", " ").ToLower();
How can I do this globally for all controllers without repeating this line in over and over?
View 1 Replies
Aug 25, 2010
I have a drop down where I want to pass the selected value I selected to the controller. How do I accomplish this?
View 2 Replies
Nov 15, 2010
I have an action:
public ActionResult Details(int? aaaID, int? bbbID)
and I am trying to route the url http://..../controller/aaa/23432 to action Details.
routes.MapRoute( "controller", // Route name "controller/aaa/{id}", // URL with parameters new { controller = "controller", action = "Details", lblID = UrlParameter.Optional } // Parameter defaults);However, the aaaID of function Details also get a null value?
View 1 Replies
Sep 8, 2010
Members view (index) that lists members that users can select to show a partial view in the same view with details for the selected memberUses jquery (Ajax.ActionLink) to call a partial view method in the members controller to then load the members detail sectionWorks fine up to here....but I'd like to load the partial view with "member" details for a default or random member on initial load -- ie not through the Actionlink selectionHow do I invoke the partial view method on the initial load?
View 4 Replies
Jun 15, 2010
My method looks like:
public static RedirectToResult(Controller controller, ...)
{
}
when I do:
controller.
I don't see RedirectToAction, how come?
I get RedirectToAction from within the controller's action, but not when I pass the controller as a parameter to another classes method.
View 3 Replies
Jan 12, 2011
I'm using a custom route to create the following URL (http://mysite/subscriber/12345) where 12345 is the subscriber number. I want it to run the ShowAll action in the Subscriber controller. My route is firing and using Phil's route debugger, when I pass in the above url, the route debugger shows ID as 12345.
My controller is accepting an int as subscriberID. When it fires, the controller throws the error "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32". Why does the route debugger show a value and the controller doesn't see it?
Here's my route (first one is the culprit)
routes.MapRoute(
"SubscriberAll",
"subscriber/{id}",
new { controller = "Subscriber", action = "ShowAll", id=0 },
new { id = @"d+" } //confirm numeric
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
I'm getting a null in the ShowAll action? Here is the action method signature:
public ActionResult ShowAll(int id)
View 3 Replies
Sep 10, 2010
code is like -
[Code]....
so in this line i am passing "ss".but in my controller i didnot get the value in a parameter variable, instead i am getting ss as parameter, not the selected ids.how can i do that.
View 2 Replies
Mar 15, 2011
[code]....
i am having problem passing in passing the url id to the controller with the form . how can i do that ?
View 3 Replies