I am an ASP.NET WebForms programmer and I'm very new to ASP.NET MVC3. I've got a dropdownlist inside the _Layout view and it needs to be populated on all the pages. I don't want to have to call some code inside every Controller, so I've moved the dropdownlist in a Partial View and put it on the page using #Html.Partial("_DropDownList"). Do I need to create a controller for this View? If so, how can I specify control it needs to use?
You might want to look at #Html.Action and #Html.RenderAction. They allow you to reference a controller action and return the output.
Related
I have two problems:
I am trying to connect a form view that is inside the content section of an accordion. I choose my ObjectDataSource, configure it and drop it on the page with the designer. When I switch back to the code view there is no code at all for the ObjectDataSource connection. When I run the page the form view displays no data whatsoever. I even told the accordion that the datasource ID was Object DataSource and it errors out saying that it doesn't exist! Why is this happening?
I need to click a button and dynamically create a new accordion pane with a blank form view that can be filled out and update the database. Theoretically I need to be able to create as many new forms as needed. How can I accomplish this?
i have a dropdown control with Listitems in Web User control. Am using the web user control in an asp .net page. using find control am able to find the control dropdown but could not get the itemlist. Can any body help me to resolve the issue...?
You should not need to use find control. Expose it as a property of your web user control instead.
If you still want to use FindControl, it is likely you can not find the item list because FindControl does not return a DropdownList. You will need to cast the control returned as a DropDownList to access its Items property
I have a partial view (using MVC2 .net) inside a view which is a form. the partial view has a textbox and is strongly typed.
The problem is I can't get the textbox data from the partial view when I post back, for some reason I can get all the view data inputs on the controller but the partial view, doesn't return the textbox data.
Can anybody help me please?
It is hard to help unless you post a bit more detail and some code. Without that here are some suggestions that might help.
You will need a submit button or some JavaScript to post the form inside the partial. If you have another form on the page which you are submitting, it will not include data from other forms and inputs on the page.
Also to form has to post back to a controller action, a partial just a helper to render a view inside another view.
How can i use dropdown selected value to asp.net mvc controller for filling another dropdown
There's a handy blog post here regarding cascading dropdowns:
http://stephenwalther.com/blog/archive/2008/09/07/asp-net-mvc-tip-41-creating-cascading-dropdown-lists-with-ajax.aspx
I'd suggest using jQuery to return a JSON result from the controller with the data for the next dropdown. This isn't great for accessibility but even in WebForms Javascript is used to postback DropDownList controls anyway.
I'm using the Infragistics tool for ASP.NET.
I have a WebForm, webform1, where I placed a WebDataGrid control of infragistics. Now, I want a user to select the row and have it redirect the data to a textbox on another WebForm, webform2.
How can I get the selected row from webform1 to webform2?
You have a number of options:
You can reference the PreviousPage property in the Page property of WebForm2. See Cross Page Posting in MSDN for more information.
You could do a Response.Redirect and then URLEncode your values and send them in the QueryString as GET values which can be referenced from the next page.
You can change your logic so that you encapsulate all of the functionality you require onto one Web Form, using either a MultiView or Wizard control.