formcollection

ASP.NET MVC - How can I pass FormCollection data in a post to another Action?

Hi everyone! I have a page "Results" with a form and when "submit" is clicked, the form is submmited to another Action. So far, so good... But, this works fine just if user is logged in. If not, he will be redirected to "Login" page and my FormCollection loses its data. Is there a way to persist this data without using TempData?? Tha...

What is correct behaviour of UpdateModel in ASP.NET MVC?

I am interested to know what you guys feel should be deemed "correct behaviour" in terms of the UpdateModel method in ASP.NET MVC. The reason I ask here is perhaps if this functionality is "by design" somebody could clarify as to why it is the way it is, and perhaps a way to call it differently to achieve desired functionality, which I ...

How to get formcollection using ajax.actionlink

I have a controller with the codes like this: [AcceptVerbs("POST")] public ActionResult Create(FormCollection collection) { //why is that the collection is null? } I am calling this action using the ajax.actionlink. my problem is the collection is null, unlike if i use the submit(input) button the formcollection has values. ...

MVC posted values

Hi Experts, In asp.net MVC application we have mechanism where, when we submit a form and if there is any problem with the values (validation fails), the form is displayed back maintaining old values. How does it happen ? Where are these values kept ? or they collected from FormCollection. Help will be apprititated. Regards Parminder...

Generic object controller in MVC, can you improve my code ?

I am creating an application that will display a list of objects in a datagrid (list of any type of object), and allow the user to update any item. The code will know nothing about the object being displayed until runtime. Can you improve my code for the update? I am using Formcollection to get items from the form and creating an instanc...

MVC2: How can I read control values for an action link?

I'm passing in some model information to an ActionLink, but I'd also like to provide the action with the values of some inputs on the page. For example, if I had something like this: <input Name="MyInput" /> <%: Html.ActionLink("MyAction", "MyController", Model.Value); I'd like the action to be aware of both Model.Value (which is pas...

Proper way of using FormCollection in ASP.NET MVC2 Create Method?

Hello everybody! I am currently developing an application with the new ASP.NET MVC2 framework. Originally I started writing this application in the ASP.NET MVC1 and I'm basically just updating it to MVC2. My problem here is, that I don't really get the concept of the FormCollection object vs. the old Typed object. This is my current ...

should formcollection be empty on asp.net mvc GET request

i am posting a simple action. public void Login(FormCollection formCollection) { ... } Even with few querystring values, the formcollection.Count is 0. Is it by behaviour? ...

Actionresult doesnt get called by routelink. Formcollection the culprit?

Hi guys. I am fairly new to MVC. I am trying to set up a search page that searches a database and returns results. The search box is within a Html.BeginForm in my View, and looks like this: <% using (Html.BeginForm()) { %> <%= Html.TextBox("searchBox", null, new { @id = "searchBox" })%> <div id="searchButtonsDiv"> ...

formcollection only holds the selected html.listbox items values? MVC

Hi all, My scenario is this: I have two listbox's, one that contains all my database items, and an empty one. The user adds the items needed from the full listbox to the empty listbox. I'm using a form to submit all the items the user has added. The problem is, only the selected items from the listbox are submitted. So if the user des...

using two submit buttons inside single form

I have a form with two submit buttons in my asp.net mvc (C#) application. When i click any submit button in Google Chrome, by default the value of submit button is the first submit button's value. Here is the html: <input type="submit" value="Send" name="SendEmail" /> <input type="submit" value="Save As Draft" name="SendEmail" /> <i...

Getting multiple checkboxes from FormCollection element

Given multiple HTML checkboxes: <input type="checkbox" name="catIDs" value="1" /> <input type="checkbox" name="catIDs" value="2" /> ... <input type="checkbox" name="catIDs" value="100" /> How do I retrive an array of integers from a FormCollection in an action: public ActionResult Edit(FormCollection form) { int [] catIDs = (IEnu...

ASP.NET MVC2 - specific fields in form pass via a specific object?

In database I have Contacts table: ContactID (int) FirstName (varchar) LastName (varchar) ... XmlFields (xml) // This field is xml type To create a new contact, I created two classes - one for regular fields and other to display fields from XmlFields field. In Controller, I have following: public ActionResult Create(Contact contact,...

what is wrong with this insert method in asp.net mvc?

My controller calls a repository class method on insert, [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude = "Id")]FormCollection collection) { try { MaterialsObj materialsObj = new MaterialsObj(); materialsObj.Mat_Name = collection["Mat_Name"]...

asp.net-mvc get a dictionary in post action or how to transform FormCollection into a dictionary

anybody knows how to transform the FormCollection into a IDictionary or how to get a IDictionary in the post action ? ...

How to build C# object from a FormCollection with complex keys

i have a javascript object, obj, that gets passed to an mvc action via a $.post() like so: var obj = { Items: [{ Text: "", Value: { Property1: "", Property2: "" }, { Text: "", Value: { Property1: "", Property2: "" }] }; $.post('MyAction', obj, function() {}); the action signature looks like this: public ActionResult M...

List box values on postback

Hi, I am using asp.net mvc. I have used two list box in one of my views. I transfer desired items from left-hand-side list box to right-side list box. On a button click, i want to get the list box contents from right side list box. I don;t get in form collection. Can anyone please suggest how can I get it? thanks, kapil ...

Converting formCollection array to objects in the controller

in my view I have several [n].propertyName array fields I want to turn the formCollection fields into objects myobject[n].propertyName when it goes to the controller. so for example, the context: View: foreach (var item in Model.SSSubjobs.AsEnumerable()) <%: Html.Hidden("["+c+"].sssj_id", item.sssj_id ) %> <%: Html.Hidden("["+c+"]...

UpdateModel for arrays in FormCollection

Hi there If I have [0].propertyname, [1].propertyname, etc in my FormCollection how would I go about updating the model? if I do this: public ActionResult Edit(int id, FormCollection collection){ IList<SoilSamplingSubJob> sssj = orderRepository.FindSubOrders_collection(id); UpdateModel(sssj, collection.ToValueProvid...

Retrieving postback from Dynamically created controls in MVC without using FormCollection

I'm passing a List to an MVC view and generating checkboxes for each object in the list (The checkboxes are named t.Name). I'd like to be able to tell which checkboxes were checked once the form is posted. However, I'd like to avoid using the FormCollection object. Is there any way to do this? ...