MVC2 Does Every Single Controller Method Have To Map To A DIFFERENT View?

Sep 16, 2010

In MVC2 does every single controller method have to map to a DIFFERENT view?Or can I make two methods map to the same view?

View 3 Replies


Similar Messages:

MVC :: Controller Class Not Available In Add View MVC2?

May 12, 2010

Hi I have created the following controller i want to add view that should have the data access class UserMagnament.Controller.menuitems but when i add view by right clicking on view folder,it is not showing "UserMagnament.Controller.menuitems" in add data class

No controller is shown such as homecontoller, accounts controller, UMController(My Controller) etc i have converted my solution from mvc 1 to mvc2. i checked the web.config. it seems ok for MVC2

[Code]....

View 6 Replies

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 :: Implement A Controller Method That Does Not Have A View

Dec 29, 2010

i have created a controller method that just update a record in the database.

and i call this method using the following code

<%
: Html.ActionLink("Perform
Calculation",
"Calculate")%>

but the problem is that when i click on the Perform Link an error will be raised indicating that it can not find the Calculate view.

so how i can enforce my application to call the Calculate controller method to perform the update and to keep the user in the current page .(the index page).

View 8 Replies

MVC :: What View Is Used When Calling A Controller Method Without ActionResult

Jan 9, 2010

I have just started using MVC. I created the MVC application and was playing around with it.When you call the http://localhost/home/Index/ on the sample MVC application the Index method of the controller home gets invoked and the view Index.aspx is displayed and similarly when we call http://localhost/home/About/ then the About method of the Home controller is invoked and the About.aspx page is displayed

View 2 Replies

Accessing Static MVC Controller Method From View

Mar 16, 2011

I've got an .aspx page with this in it:

<%@ Import Namespace="System.Web.Mvc" %>
<%= AssetController.ScriptTag("/js/Community/CommunityWizard.js")%>

And I have an AssetController class:

Imports System.Web.Mvc
Public Class AssetController
Inherits Controller
Public Shared Function ScriptTag(ByVal src As String) As String
Return String.Format(
"<script type='text/javascript' src='/js.mvc?src={0}&{1}'></script>",
System.Web.HttpContext.Current.Server.UrlEncode(src),
New BuildVersion().ToString()
)
End Function
End Class

The project has a reference added to the 3.0.0.0 version of System.Web.Mvc assembly. When I try to view the page in a browser, I get a HTTP 500 with this message:

BC30007: Reference required to
assembly 'System.Web.Mvc,
Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'
containing the base class
'System.Web.Mvc.Controller'. Add one to your project.

What gives? I don't understand why I can use this controller everywhere in our ASP.NET Forms/MVC hybrid application, but not in a view. EDIT: In fact, when I type <% System.Web. into the .aspx view, Mvc doesn't even appear in Intellisense!

View 2 Replies

Fill View Page Of This Controller Method?

Apr 23, 2010

Why will not fill View page of this controller method

public ActionResult Person()
{
testEntities6 testPersons = new testEntities6();[code].....

View 1 Replies

MVC :: Can't Reach Controller - Javascript Library And Method Called From View

Jul 23, 2010

I have a javascript library and in there i have a method that is called from my view. Here it is:

<li><a href="javascript:void 0" onclick="deleteAll('image', '<%= ViewData["FileGroupId"]%>')"><div><%=GetGlobalResourceObject("default", "Delete_all") %></div><div></div></a></li>
and here is my js code in the javascript library:
var deleteAll = function(module, groupId) {
jConfirm(_deleteConfirmAll, _deleteAll, function(r) {
if (r) {
showProgress();
$.ajax({
cache: false,
type: "POST",
url: _baseUrl + "/" + module + "/deleteall/" + groupId,
success: function(msg) {
if (msg == '0') {
location.href = _baseUrl + '/' + module;
}
else {
jAlert(msg, _errorTitle);
}
hideProgress();
}
});
}
});
}
My problem is that i cant reach my controller. Here is my controller code:
#region common methods
List<.CMS.Core.File> GetList(int groupId)
{
List<CMS.Core.File> list = new List<CMS.Core.File>();
CMS.Core.FileFilter filter = new CMS.Core.FileFilter();
filter.GroupId = groupId;
int res = CMS.Core.File.Search(_connection, filter, ref list);
return list;
}
#endregion
public ActionResult DeleteAll(int groupId)
{
List<CMS.Core.File> list = GetList(groupId);
foreach (File item in list)
{
item.Delete();
}
return Json(list);
}
And at last her is my Index method
public ActionResult Index(int? id)
{
if (Request.IsAjaxRequest())
{
JsonPaging paging = new JsonPaging();
int offset = 0;
int page = 0;
if (!String.IsNullOrEmpty(Request.QueryString["page"]))
{
Int32.TryParse(Request.QueryString["page"], out page);
}
if (page > 0)
{
offset = (page * paging.PageSize) - paging.PageSize;
}
FileFilter filter = new FileFilter();
filter.Deleted = false;
filter.MaxRecords = paging.PageSize;
filter.Offset = offset;
if (!String.IsNullOrEmpty(Request.QueryString["keywords"]))
{
filter.FilterType = FilterTypes.AND;
filter.Name = Request.QueryString["keywords"].ToString();
}
if (!String.IsNullOrEmpty(Request.QueryString["sort"]))
{
filter.OrderBy = Request.QueryString["sort"].ToString();
if (!String.IsNullOrEmpty(Request.QueryString["direction"]))
{
filter.OrderBy = filter.OrderBy + " " + Request.QueryString["direction"].ToString();
}
}
if (id > 0)
{
filter.GroupId = id.Value;
}
List<CMS.Core.File> items = new List<CMS.Core.File>();
int results = CMS.Core.File.Search(_connection, filter, ref items);
foreach (CMS.Core.File current in items)
{
JsonItem item = new JsonItem();
item.Id = current.Id;
item.Name = current.Name;
item.ImageText = current.ImageText;
item.Aperture = current.Aperture;
item.TakenOn = current.TakenOn;
item.Camera = current.Camera;
item.ExposureTime = current.ExposureTime;
item.FocalLenght = current.FocalLenght;
item.Tags = current.Tags;
item.Url = current.Url;
item["Active"] = current.Active.ToString();
item["Created"] = current.Created.ToString();
paging.Items.Add(item);
}
return Json(paging, JsonRequestBehavior.AllowGet);
}
else
{
ViewData["FileGroupId"] = id;
return View();
}
}

View 2 Replies

MVC :: Getting The Reference Of Dropdown Server Control In The Action Method Of View Controller

Dec 30, 2010

I am having a dropdown server control on view, when the user clicks the submit btn at that time the form gets posted. and a action method in view controller is called with verb=post.

But the problem is that how should i get reference to the dropdown server control in the action method of view controller?

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

MVC2 - How To Return A File From A Controller

Nov 23, 2010

Possible Duplicate: How to create file and return it via FileResult in ASP.NET MVC?

ASP.NET MVC2: How to return a file from a controller? I want to do this so the user can download the file from server.

View 1 Replies

How To Pass Html Table Data To Controller In Mvc2.0

Dec 15, 2010

I have a HTML table (grid). I want to pass the html table data to controller.(mvc 2.0)

View 2 Replies

MVC2 View Model For Multiple View Forms And Data

Aug 26, 2010

one thing that has been puzzling me since learning MVC2 is the following case scenario: I have a view which contains two latest news lists, a login form and a signup form. Every example I found on Views and View Models so far has a one-to-one example such as a simple login form etc. But how do I create a model that provides the properties and validation for a login and signup form and manages the data for the news lists. can I pass multiple models in the strongly typed view? When I created one model the form validation would fail as it expects all fields - login and signup to be filled. I am missing some advanced examples or information.

View 2 Replies

How To Send Complex Types To MVC2 Controller Via Jquery (Ajax )

Feb 22, 2011

I am posting a Jquery Json serialized object to my controller but not all of the data is getting passed. One of the members is a complex type that is also Json serialized. This is the one that isn't getting through to the controller.

Here is the class I'm passing to my controller via Ajax post. Note the complex type, RoutingRuleModel.

SourceCodeModel.cs:

[code]....

Problem: SourceCodeModel contains correct values EXCEPT for it's complex member: RuleModel, which comes back as a RoutingRuleModel with default (null or 0's) values.

View 1 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

Proper Way Of Using FormCollection In .NET MVC2 Create Method?

Jan 28, 2010

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 code:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(FormCollection collection)
{[code]....

What are the benefits of switching to FormCollection in MVC2 and more importantly - how is it used properly?

View 2 Replies

Register A Single Controller?

Aug 7, 2010

The code below works for adding all controllers:

container.Register(AllTypes.Of<Controller>().FromAssembly(typeof(MvcApplication).Assembly).Configure(c => c.LifeStyle.Transient.Named(c.Implementation.Name.ToLower())));

But I want to add them one at a time. Nothing I try works (example below). How do I code this?

container.Register(Component.For<CategoryController>().LifeStyle.PerWebRequest);

View 2 Replies

MVC :: Create A Partial View And A Controller That Will Feed Data To the View?

Jan 27, 2010

Can i create a partial view and a controller that will feed data to the view, and if i render that partial in a Master page, the Data will show on whatever URL i am?

Or is there another way of showing content from database on every page(view)?

View 2 Replies

MVC :: Using Data From Multiple Entity Framework4 Model Entity Objects In MVC2 Controller?

Sep 29, 2010

getting data from multiple Entities models into an MVC controller. Most of the examples I have seen for using EF in an MVC2 app only use a single entitiy.

I have just started using MVC2 in C# using the Entity Framework models (CIOps.model) created from an SQL database. I can create the controller and views using single tables of the model in MVC2, but I just cannot get my head around how to get data from multiple entity tables into the controller (similar to joins in T-SQL). I have included an example below of the controller code that works with a single entity table, tbl_tours (tbl_tour in DB).

Could someone please illustrate how this code would be changed to include additional columns from FK tables in addition to tbl_tours columns. E.g. the clients name from the tbl_clients, the coordinators name from the tbl_employees, and costs from tbl_costs entities? Is it possible to do this directly using the EF model entities/classes that are already created and not use LINQ, POCO, Repositories, etc.? The FK relationships are already in the EF models. I have included the whole controller code, but I just need a few examples of how to join the multiple entities, not rewrite every CRUD function function in the controller. I think this will get me over the hump in using EF in an MVC2 App. Also ignore the fact I am using the home controller, this will change in the application.

[Code]....

View 21 Replies

C# - Update A Partial View From Another - MVC2

Sep 20, 2010

I want to have two partial views, one for SEARCH and one for SEARCHRESULTS. I want to update SEARCHRESULTS when the "Search" Button is clicked on the SEARCH partial view form. SEARCHRESULTS needs to have the form data fed to it from the SEARCH partial view. I'm not totally sure how to go about this. Can I update the SEARCHRESULTS partial view from my SEARCH partial view's Controller action?

View 1 Replies

Printing A View Page In Mvc2?

Nov 29, 2010

i'm developping one asp net mvc2 projet.what i need is that i want to print the view when user click link someone have idear

View 2 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 Create View Form In MVC2 Application

Feb 10, 2011

am trying to create view form in my MVC2 applicationIn this i have a submit button which is an imagebut when i try to run it shows a normal windows button the image is not shown(the image is a round edged).the code is as below:

<input type="submit" value="Log On" id="login_button_75" />
#login_button_75 {
background:url(images/login_submit_button.png) no-repeat;
height:28px;
width:75px;
background-position:center;

View 6 Replies

MVC2: How To Render A View If Has Multiple Different Models

Dec 12, 2010

I know that view model can be used for rendering a view, but if a page needs different models, how can I pass them to the view? And how do I use them?

View 2 Replies

Can Inherit A View Of Mvc2 From Normal Master Page

Apr 29, 2010

Can I Inherit a view in asp.net mvc2 from normal asp.net master page

View 2 Replies







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