Import A Collection Of Values In A Controller Using MEF?
Oct 22, 2010
I have an ASP.NET MVC2 application that supports visualization plug-ins/providers. The IVisualization interface is defined in a common assembly which is referenced by both the ASP.NET MVC2 app, and any visualization providers.
In the Visualization controller, I have a method which returns all the applicable visualizations for a given set of data. In order to scan the available providers, I use the following code in the controller's ActionMethod.
var catalog = new DirectoryCatalog(HttpRuntime.BinDirectory);
var container = new CompositionContainer(catalog);
var visualizations = container.GetExportedValues<IVisualization>();
However, I feel like if I have the following in the controller
[ImportMany] public IEnumerable<IVisualization> Visualizations { get; set; }
then the import should happen automatically. What am I missing that prevents the automatic imports?
Also, is the code that I am currently using going to kill scaling of website?
View 2 Replies
Similar Messages:
Apr 17, 2010
How to pass model bind collection from one controller to another?
I have this model class,
Public Class Sports
Private _SportsID As Integer
Private _SportsName As String
[Code]....
View 3 Replies
May 30, 2010
I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.
How can I persist values from controller to controller?
Should I use Session? TempData?
I am using Structure Map for IOC.
Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?
View 10 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
Jun 20, 2010
I'm using HttpModule to capture requests to the web server. Before processing the page I'd like to check the values contained in some keys of the Request.Form collection and according to some logic change if necessary. I'd like to do this when BeginRequest event is fired. The problem is that the Request.Form collection is readonly.
View 4 Replies
Oct 19, 2010
Not that it should matter.. the 2nd value in the csv is an IP address.. its in the file as 192.168.7.25(just an example), but gets read as 192.1687, if the file is setup as delimited in the connection string, does that have any restraints on the data being read? When i open the file in notepad, the comma is at the end of the IP address, when i open it in excel it is in its own column.. so what could be causing this? Because of this issue with the truncation, that is what is causing the primary key issue.. because there are other values that are similar like these:
192.168.7.25
192.168.7.26
192.168.7.45
because if the issue, it passes each one of those as 192.1687 Here is the table structure, in case it helps resolve this issue.
[id] [int] NOT NULL,
[IpAddress] [varchar](16) NOT NULL,
[MacAddress] [varchar](16) NULL,
[APTypeId] [int] NOT NULL,
[APUser] [varchar](256) NULL,
[APPass] [varchar](128) NULL,
[APLocation] [varchar](20) NULL,
[APFreq] [varchar](50) NOT NULL,
[APBand] [varchar](50) NOT NULL,
View 5 Replies
Sep 28, 2010
Upon clicking a button I need to send a collection and a few other variables to server in Json form.For each value in the collection the server code (C# ) wil update those other variables in the DB.
For example there is a ‘classnumber’ collection with values (First, Second, Third, ….),other variables (‘teacher_name’ and ‘subjectname’).For each value in the ‘classnumber’ collection I need to update the ‘teacher_name’ by searching for the ‘subject_name’ in the DB.So I need to pass the ‘classnumber’ collection,’teacher_name’,’subject_name’ values to server in json form. At the moment instead of sending the ‘classnumber’ collection I am sending ‘teacher_name’,’subject_name’,’classnumber’ as variables for each value in the collection ,which requires multiple requests made to the server.
Instead of these individual requests I am wondering if there is a way to send all the data at once to server in json form?
View 1 Replies
Aug 6, 2010
Given the following InsertItemTemplate (simplified) I'm not getting anything back in the event object's Values collection.
[code]....
I'm binding the listview to a collection attached to my nHibernate model object (SearchObject.SearchItems). This collection doesn't have insert or update handling like an object datasource would, so I want to handle the insert/update events manually. Is there a way to get these values to come through automatically, or do I have to manually grab each value from its control when I handle this event?
View 1 Replies
Jul 27, 2010
I am creating a presentation on basis of some selected values and maitaning the selected values in a session variable named Session("userPref") in collection form.
Now I am opening a TablePreview.aspx page by javascript window.open() function.
On Page_Load of TablePreview.aspx I am reading some values of Session("userPref") and doing some operatons.
For saving the presentation I have created a page wizardsave.aspx.
Now I am opening the wizardsave.aspx from TablePreview.aspx by window.open() function for saving presentation, but on Page_Load of wizardsave.aspx. I found that some value from collection stored in Session("userPref") have lost.
View 4 Replies
Mar 22, 2011
the problem is that i am not able to recieve any value in the controller . what could be wrong? the code is here.
[Code]....
View 2 Replies
Apr 23, 2010
I am having a form in a view page that looks as below:
[Code]...
Now when the form is posted, I am trying to retrieve the values submitted in the controller as below:
[Code]...
The string value shows null when I submit the form by checking some checkboxes. Is this the way to retrieve the values or am I doing something wrong? And I cannot use html control because all other controls on the form are server controls and I am not sure if I can only make this control a html control. And I am not sure how can I bind the values to it?
View 2 Replies
Mar 20, 2011
Can I reach the value of hidden fields in controller action ? And how ? Do I put it in the model somehow ?
EDIT: some code example how to store something in hidden field and retrieve it on postback.
View 1 Replies
Apr 8, 2010
the code for getting the dropdown selected values (both TextField and ValueField) in MVC Controller class.
This is my case, I have a dropdown filled with Product category. Its having default value as "--Select--". I want validate this dropdown selected any values or not in controller action method. How will i do this stuff?
View 4 Replies
Jan 26, 2011
I'm working on a mvc project that builts a table of items and each row has a button to submit that row to the controller. Now each button has an id and I use hidden input to store the data in that column. How do I post the id to the controller? I use Html.beginform() at the beginning and a submit button. I want the ID to appear in the URL so I can extract the data based on that.
Also I can see that my values are posted but they don't show up in the query string. How do I get these values in the controller? The code is like this. [Code]....
View 2 Replies
Oct 8, 2010
I am trying to read a file from a disk.
I have a form with 2 drop down lists and a 2 text areas and a File upload.
I am doing file upload by following way-:
<input type=file id="fileurl"></input>
How can i get this complete file name and the other form values in controller.
View 2 Replies
Jan 20, 2010
I'm having problems passing values from the controller to the view. I created a boolean variable to use as a flag and want the view to render some html based on whether its true or false.
Unfortunately ViewData doesn't look like it can pass boolean values. I should be able to pass any datatype to a view (string, int, bool, etc...)
View 16 Replies
Mar 17, 2011
may I ask one seemingly simple question - I have a Javascript function that loops through my checkboxes(they're plain HTML checkboxes, not using the helper methods), and for every checked one it's adding its value to an array. So now, how do I get this array in my controller so that I can assign its values to the fields, i.e. object's properties?
This is my checkbox code:
[Code]....
and the script:
[Code]....
and here's the controller code:
[Code]....
Now, this langID should be assigned every checked checkbox's value, so I guess I'm missing a loop here too, it should go until some border that's gotten from the client script or something, but my bigger problem is how to retrieve the posted values from the javascript, something like PHP's POST["array"]...?
This Request.Form works fine when just one checkbox is checked, but now I need it to work with several checked..
View 12 Replies
Mar 24, 2011
I am working on Tenant module that has to display following fileds, Tenant Id, Tenant Desc, Contact Person, Contact Phone. In the DB, these are designed as two separate tables - Tenant and Contact. Tenant table has Tenant Id, tenant Desc and Contact Id . Contact table has all the contact related properties. I am using EF as DAL.
To make my system loosely coupled, I have created a repository pattern to talk to EF entities. Also, for validation I am using service layer.
My repository layer has two interfaces and classes corresponding to Tenant and Contact.
public interface ITenantRepository : IRepository<Tenant> // IRepository<T> is a generic interface for CRUD operations
{
Tenant Get(int id);
IEnumerable<Tenanr> List() ;
[Code]....
View 4 Replies
Nov 26, 2010
I added by client form elements to capture values at server.
[Code]....
How I get values theses inputs at Post?
View 3 Replies
Dec 28, 2010
UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.
View 1 Replies
Apr 23, 2010
I have a data import page where I start the Import by clicking a button.Second by second I want to print in Web Page informations about record is being importing.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="CurrentTimePanel" runat="server">
<ContentTemplate>
<asp:Label ID="CurrentTime" runat="server" Text="Now: " />
[code]...
View 5 Replies
Mar 22, 2011
how to pass values from ascx page contains [ 3 textboxes] to controller
View 2 Replies
Feb 15, 2010
I have created a Search page inside the Home section and is handled by the HomeController.Inside the HomeController I created a custom ActionResult called Lookup():
[Code]....
View 2 Replies
May 11, 2010
I have an editable table in my view.
how can i accept the whole table in a controller action method?
what parameter should i gave to accept the whole table
View 1 Replies
Aug 25, 2010
Currently, I am working with ASP.NET MVC1 and am still learning about Model Binding and how values from a View are passed back to the Controller / Model. Specifically, I want take an existing Model, create a Table and populate the Rows of the Table, allow the user to edit some fields and pass it back. In my example, I have a Class called "Ingredient" which has 4 public accessories: Name, Barcode, Amount, and Unit.
[Code]....
Or is this not possible? (Basically, I'm trying to re-create a datagrid where certain fields are editable and certain are not...)
View 2 Replies