Action method takes as id parameter and returns 2 lists (eg. List<object1> and List<object2>) of objects back to the view. In order to achieve this, the viewmodel is created as below;
have some Objects, lets say Employee and Role defined as below and I have defined relationships in my database that gives me a list of objects say employees and thanks to my framework each employee object also has a Role object linked via the RoleIDID, UserName, Password, Email, RoleIDRoleID, RoleNameSo in code I can do something like this
I know how to bind a simple objects to a dropdown list. However I am having problems binding my objects which contains sub objects to the control.i.e. with simple object i just do ddl.DataValueField = "myproperty" with my objects they contains sub objects which i want to bind. I have tried ddl.DataValueField = "sub-object.myproperty" which doesnt work.
i have a web for and want to 'get' it to another page.. is there anyway to submit it without posting the viewstate and other bits i dont want? or should i be catching the submit button click and redirecting with a querystring i build myself
I have a page with two forms on it. The first form is a "Search" form and does not have the runat="server" attribute. It is merely meant to post some search criteria to another page on the site. The second form is the standard "aspnetForm". Inside that form I have a ModalPopupExtender... Within the ModalPopupExtender there are two buttons that should postback to the server when they are clicked by the user. My problem is that when the buttons are clicked the page posts back to the "Search" form... The only clue I have is that if I move the form to the bottom of the page (after my ModalPopupExtender), everything works fine. It seems that the extender uses the first form it can find on the page. Is there anyway to force it to postback to the correct form?
I have a user control I am adding dynamically. It has a link button and a text area on it. The containing div is hidden via style sheet (client side), and I use some jquery to pop it up in a modal. It is getting added in the init and the button click event is firing on the server. BUT the textareas value is not being set. On further inspection the field value is not even being sent in the form POST data. why the value is not being sent. The rest of the form values are being sent with no problems.
this page I will be calling from a variety of pages. Is there some way of knowing from which page my form was submitted? I was thinking something along the lines of writing:
I have an application that needs to post data to a url on the web and then receive an xml response. I have an HTML form (provided by vendor) that posts the data correctly, however when clicking the submit button the page is redirected to the post url and the xml is displayed in the browser. I need to do this on a postback within an existing asp.net project. Basically, the user will fill out the form, the form data will post to the url, the xml response will be received, and the appropriate values will be displayed on the screen. I've found a bunch of examples for doing this but I just can't seem to get my head around it. Can anyone point me in the right direction or explain how I should go about this?
In my ASP.NET MVC 2 web application, I allow users to create custom input fields of different data types to extend our basic input form. While tricky, building the input form from a collection of custom fields is straight-forward enough.However, I'm now to the point where I want to handle the posting of this form and I'm not certain what the best way to handle this would be. Normally, we'd use strongly-typed input models that get bound from the various statically-typed inputs available on the form. However, I'm at a loss for how to do this with a variable number of input fields that represent different data types.A representative input form might look something like:
My date field: [ date time input control ] My text field: [ text input field ] My file field: [ file upload control ] My number field: [ numerical input control ] My text field 2: [text input field ] etc...
Ideas I've thought about are:Sending everything as strings (except for the file inputs, which would need to be handled specially).Using a model with an "object" property and attempting to bind to that (if this is even possible).Sending a json request to my controller with the data encoded properly and attempting to parse that.Manually processing the form collection in my controller post action - certainly an option, but I'd love to avoid this.Has anyone tackled an issue like this before? If so, how did you solve it?Update:My "base" form is handled on another input area all together, so a solution doesn't need to account for any sort of inheritence magic for this. I'm just interested in handling the custom fields on this interface, not my "base" ones.Update 2:Thank you to ARM and smartcaveman; both of you provided good guidance for how this could be done. I will update this question with my final solution once its been implemented.
I have view that dynamically adds multiple partial views with a foreach statement with the standard <%Html.RenderPartial("partialName", model); %> . The partial view control has just a label and textbox control. When I view the source html generated it correctly has a single form control around all the multiple labels and textboxes. My single submit button, inside the form though does not send any of the form data back to the controller though when using FormCollection.
I got a list of checkboxes on my form, and a jquery script that catch a button click to get all the selected items (in an array) and post to a controller action.
This is my script: (yes A, looked at your sample but cannot get this to work)
[Code]....
That alert will print out correctly (like 1,3,5).
However when the above post hit my controller action, "selectedInvestments" are null, which I can't figure out why (back to my tekpub jquery videos, can't go on like this)
Currently i am having a list like List<Tickets> allTickets.I need to select in the same list some corresponding info about the ticket writer like List<Ticket, aspnet_User>.
I have an Edit form that utilizes the following ViewModel:
[Code]....
SUserDetail, User and CUDetail are LINQtoSQL classes in my [ .dbml ]. What the above ViewModel allows me to do, is provide a nice and neat Edit form populated with data from the above 3 objects.
However I am stuck on how to handle the HTTP Post for the Edit Action.
I have a list of objects (List1) and I am trying to make a copy of this list (List2) and then change one of the fields in the new list.I used :
List<MyObj> List2 = new List<MyObj>(); List2.AddRange(List1); I alos tried: List<MyObj> List2 = new List<MyObj>(List1); But regardless of the method, when I do: foreach (MyObj o in List2) o.some_field = 2
it not only changes the field in Lis2 but alos in List1. Not sure what I am missing here.
I have a list of objects and I would like to create my own custom control that pages through the list using Jquery to make the Ajax calls to my pager methods. I've had some experience with Jquery but need a helping hand and I really don't want to use update panels etc. So the scenario is.....user clicks next, the C# method is called using Ajax, the code gets the relevant data and sends re-populates the UI with the next item in the list.
I'm using asp.net mvc2 and trying to send a list of json objects with hard coded values from the home controller, and receive them in index.... in the code below i'm sending 1 json object. how do i send many?
I have a List of objects in an asp.net page. when the page loads in the browser for the first time, I fetch data from the database, create objects with those data and populate the list. All these are done inside the page load event handler. Now when the page is posted back to the page, the previous list is gone, since the variables were all freed.
How can I cache that List, so that when this page is posted back, all my objects are available?
I am making my first attempt at using RenderPartial to display a list of objects, but so far having little success. Here is my code, can somebody give me some guidance on what I am doing wrong?
I finding myself repeating myself and the DRY side is nagging me to find an abstraction. I have a number of different entities in an MVC3 Razor web app. They are all business objects and each has a number of different properties that I show to the user in a list. So I have Index views and List partial views for each of these different entities (there are at least 10). I would like to abstract the List partial view so that it's capable of displaying a list of any type of entity. It simply shows them in a table with a column for each property and a row for each entity. My current thinking is that I could receive a list of objects and then use Reflection to see what properties those objects have and use those to make columns. I really wish I could receive a generic List somehow and from my various controllers just pass in an anonymous object (new {Parameter 1=param1, Parameter 2=param2}, etc.) but then I discovered that it's not possible to pass anonymous objects around.