C# - Using Grasp Controller With MVC Controller - How To Make An Object Always Visible For A Controller

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


Similar Messages:

MVC :: Out Of The Box MVC2 Controller / Delete Controller Is Refusing To Return Any Class Information

Nov 6, 2010

my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.

Function Delete(ByVal id As Integer) As ActionResult

View 4 Replies

MVC :: Pass Parameter From Controller To View And Back To Another Controller?

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

MVC :: Session Vs TempData / How To Persist Values From Controller To Controller

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

MVC :: Get The Current Action / Controller Name In A Controller Or Class?

Mar 14, 2011

How do you get the current action / controller name in a controller or class?

i can't show it in my view but that's not what i want.

View 1 Replies

MVC :: C# Controller Works, VB Controller Doesn't ?

Jul 22, 2010

C#: HomeController.vb: works fine HttpPost RsvpForm gets the object filled with user input.

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using RsvpInC.Models; namespace RsvpInC.Controllers{ public class HomeController : Controller { //
[code]...

View 5 Replies

MVC :: Calling Action Of A Controller From Another Controller?

Jan 24, 2011

I have a User entity and a department entity. I have a UserViewModel and DepartmentListModel which has List of departments.

UserViewModel has a property of type DepartmentListModel .

Now on user/create action I need to populate DepartmentListModel by calling DepartmentController's list action. List action returns populated DepartmentListViewModel.

From UserController how do I set DepartmentListModel ?

I tried doing so

[Code]....

But RedirectToAction returns RediretToRouteResult

View 7 Replies

MVC :: Area Controller To Inherit "Shared" Controller?

Mar 11, 2010

Say I have several Areas that are baed on user roles.Differnet roles have different functionality, but also have some "shared" functionality like say "Payments"Now, I created a PaymentController (and it's views for listing, creating messages) in Shared (not an area) and it works fine.

Would it be possible (and how?) to create a PaymentsController class in one of the Areas, have that inherit the PaymentController Class in Shared?

If I can do this, I can successfully share common functionality across areas, and at the same time extend the derived controller to include some 'area specific' functionality to common shared controllers. (Such as the "REturn to xxxx" text and route of the returnurl, which are a bit more complicated than I just made it sound)

View 3 Replies

MVC :: Make A Method Controller?

Apr 9, 2010

I have a foreach in my view and inside foreach I create a control with unique name:

[Code]....

so, form can have checkboxes:

<input type="checkbox" name="IsProjectA" />
<input type="checkbox" name="IsProjectB" />
<input type="checkbox" name="IsProjectSomeName" />

how to get their values on post method controller (what is the best way).

View 2 Replies

MVC :: Make A Div On The Page Hidden From The Controller?

Oct 13, 2010

I'm trying to realise how to make a div on the page hidden, from the controller.

the situation is this:

i have 2 radioboxes, which need to fill a hidden label with thier value, dependant on the one selected.

the second case is gettin the value in the ID part of the link, and hiding the radioboxes altogether.

been googling it for hours and could not find a solution for this?

View 8 Replies

MVC :: Pass Javascript Object Value To Controller?

Feb 9, 2010

Consider the following data

<xml>
<id>10</id>
<value1>15<value1>
</xml>

I need to use this data as an input to ajax request. For eg. consider a dropdownlist change event, I need to pass these values to the controller.

sample code

//dropdown change event
$("#TestReqID").change(function() {
var id = 10;
var testResults = "abc";
var inXML = "<xml>";
inXML = inXML + "<id>" + id + "</id>";
inXML = inXML + "<value1>" + testResults + "</value1>";
inXML = inXML + "</xml>"
$.getJSON("/Home/UpdateTest/Json/" + inXML, function(data) {
//success code goes here
});
});

in HomeController

public ActionResult UpdateTest(string obj)
{
if (HttpContext.Request.IsAjaxRequest())
{
/*
Need to parse data in "obj" from ajax request
*/
IPTests test = _service.GetIPTest(Convert.ToInt32(id));
return new JsonResult { Data = new { ipTestId = "0", testResults = "" } };
}
return View(test);
}

instead of xml string is it possible to use javascript object like

[Code]....

View 2 Replies

VS 2013 - Getting ApplicationUser Object In A Controller

Jul 13, 2014

I am writing a C# MVC5 internet application and am having some trouble getting the 'ApplicationUser' object in a controller that I have created.

Code:
var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
ApplicationUser user = userManager.FindByNameAsync(User.Identity.GetUserId()).Result;

When I try to run this code, when a user is logged in, I am getting a null object for the 'ApplicationUser' user.

View 1 Replies

MVC :: How To Transfer Control To A Controller's Method From A Controller's Method?

Jan 19, 2011

How can i transfer control to a controller's method from a controller's method..I am having two Controllers Home and User.. After username and password are verified inHome Controllers method , i want to show the User Controllers index page , so i have to callindex method of Home controller..How can i do it.

View 5 Replies

Avoiding The Use Of The Viewdata Enumerable Object In Controller?

Mar 23, 2011

I have 2 points for today I. I have a controller in which i have a public static method for getting the details for a checkbox like

[code]....

is it ok for me to use this same function like this one in the view, so that I do not need to use the viewdata object,

<%: Html.DropDownList("country", new SelectList(UserController.GetCountryLists(), "value", "countryname", "0"))%>

Also i have another query, when i use the same id & name for the radiobuttons, validation at the client side is working fine.If I use the same condition for a group of checkboxes, i get do not get the checkboxes highlighted during client validation and only during server validation, i get the error message, but the controls [checkboxes] do not have a red border indicating the error.I have used my own html helper to generate the checkboxlist as per [URL].

View 1 Replies

Bind Object To The Controller, To Show Some Properties Value?

Feb 17, 2011

I'm a junior ASP.NET developer comes from Java background, so may be my question is strange.

I want to build an ascx (asp control) which accept an object as parameter for example :

1- we have a class called Device ( Contains some properties name, color , Specification (another object))

2- we have a control DeviceItem ( Contains Table to view some of the Device properties value ) and contains a property called Device

if the devices object retrieved from the Database and we have an object called device1 from Type Device

is there a direct way to pass the Device object (device1) to the DeviceItem control, some thing like :

<uc1:DeviceItem ID="DeviceItem1" runat="server" Device="THE_DEVICE_OBJECT"/>

and then bind this object to the controller, to show some properties value?

View 4 Replies

MVC :: How To Create List Of Custom Object In Controller

Jan 2, 2011

In my controller I fetch a list of object 'object1' which has two fields field1 & field2.Now I have a model model1 which has two fields fieldsX & fieldY.fieldX = field1fieldY = dosomething(field2 also have a view model ViewModel1 which has a single fieldpublic List<model1> model2I need to send model2 to my view

View 4 Replies

Passing A List Of Object From A View To The Controller In Mvc?

Mar 26, 2010

ss a list of objects as a paramter in an actionlinkAt the moment when I try to do this the list is always empty by the time it reaches the controller!

<%= Url.Action("ActionName", new { list = Model.ListOfObjects}) %>
public ActionResult ActionName(List<Object> list)
{
//Do stuff
}

View 3 Replies

MVC :: Instantiate HtmlHelper Object In Controller Action?

Jun 10, 2010

Is it possible to instantiate an HtmlHelper object in a controller action in order to call HtmlHelper.EditorFor?

I would like to call HtmlHelper.EditorFor to return some partial html generated by an editor template in response to an ajax call. If I can do so I would not need to create an ascx file that otherwise would do the call to EditorFor.

View 2 Replies

Make Mvc Configurable Html.ActionLink Controller / Method

May 7, 2010

I have ascx partial view with html-layout like that

<%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, ... )) %>

My ascx is pretty big & I'd like to reuse it, changing controller/method in Html.ActionLink with another controller/method. Method of another controller has the same signature as PersonController.Publications. Whats best way how to make controller/method configurable for my layout.

View 1 Replies

Passing Data From Controller To View Using JSon Object

Mar 4, 2011

I have the following to get the Json abject passed from the controller and populate the various textboxes in the view. However, nothing is happening even though controller is passing a valid Json object. What is wrong with this code?

<script language="javascript" type="text/javascript">
$(document).ready(function() {
var url = '<%=Url.Action("DropDownChange") %>';
$("#vendorID").change(function() {
var selectedID = $(this).val();
if (selectedID != "New Vendor Id") {
//$.post('Url.Action("DropDownChange","Refunds")', function(result) {
$.post(url, { dropdownValue: selectedID }, function(result) {
alert(selectedID);
$("#name").val(result.Name);
$("#city").val(result.City);
$("#contact").val(result.Contact);
$("#address2").val(result.Address2);
$("#address1").val(result.Address1);
$("#state").val(result.State);
$("#zip").val(result.Zip);
});
}
});
});
This is the code in my controller;
public JsonResult DropDownChange(string dropdownValue)
// This action method gets called via an ajax request
{
if (dropdownValue != null && Request.IsAjaxRequest() == true)
{
paymentApplicationRefund =
cPaymentRepository.PayableEntity(dropdownValue);
paymentApplicationRefund.Address1.Trim();
paymentApplicationRefund.Address2.Trim();
paymentApplicationRefund.Name.Trim();
paymentApplicationRefund.City.Trim();
paymentApplicationRefund.Contact.Trim();
paymentApplicationRefund.State.Trim();
paymentApplicationRefund.Zip.Trim();
return Json(paymentApplicationRefund,"application/json");
}
else
{
return null;
}
}

View 3 Replies

Javascript - How To Pass Json Collection Object To Mvc Controller Action Method

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

C# - Implement System.Web.Caching.Cache Object In A Controller To Cache Specific Query?

Mar 29, 2010

Is it correct to implement my caching object like this in my controller :

[code]....

And I Use it like this :

[code]....

View 1 Replies

MVC :: Passing Model Object To View And From View To Controller?

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

How To Get Value From View To Controller

Nov 20, 2010

I have a View:

<div class="editor-field" id = "nick">Nick <%: Html.TextBoxFor(model => model.Nick)%><img src="/Content/Images/loading.gif" alt = "loading...."/>
<%: Ajax.ActionLink("Check", "Check", new AjaxOptions { UpdateTargetId = "check-valid", LoadingElementId = "loading"})%>
</div>

I used: Nick = ViewData.Model.Nick in ActionLink as below, but I cannot get value of Nick from View.

<%: Ajax.ActionLink("Check", "Check", new {Nick = ViewData.Model.Nick}, new AjaxOptions { UpdateTargetId = "check-valid", LoadingElementId = "loading"})%>

View 1 Replies

How To Get The Id Value In Controller / Action / Id

Sep 24, 2010

I have an edit application view, and it can be found at the following URL:

http://localhost:17262/Application/EditApplication/1

1 equals the application ID.

Also on the page I have a link that goes to another view to add an assistant for the application. I want to pass it the application ID so that the new assistant can be "linked" to this application. How would I get the value of 1 and add it to my action link? This is what I have in my HTML so far:

<%: Html.ActionLink("Add New Assistant", "Create", "Assistant", new { applicationID = "id" }, null) %>

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved