MVC :: Multiplie Views For One Action?

Aug 23, 2010

I'm trying to make a management panel for my controller "Products". People should be able to visit http://something.com/products and see a complete list of the products and be able to order etc.. The administrator should be able to log into a management panel where he can edit the product list (edit/add/delete), now is my question how can I render the management page for Products and still be able to visit the regular product list that customers see?

View 3 Replies


Similar Messages:

C# - How To Return Two Different Views From The Same Action In .NET MVC

Jan 13, 2011

I have two views which will both use the same Controller method:

//webServiceController.cs

//The actual method is about 40 lines of code. Truncated for readability.
public ActionResult Index()
{
object i = new List<WebServiceMethod>(); [code].....

The second view is a quick'n'dirty conversion to JSON so that I can do magical AJAX tricks with the data:

<%
// AjaxGetServiceData.aspx

// Convert web service response object into JSON for AJAX.
var jss = new System.Web.Script.Serialization.JavaScriptSerializer();
Response.Write(jss.Serialize(Model));

%>

I'd created a duplicate of the Index() method and called it AjaxGetServiceData(), but that defeats the purpose of MVC.

Resolution:I didn't ask my question very well, as evidenced by a 5-10 minute discussion I just had with a coworker about this very topic. He kept asking me the same question that many users on this page asked me: "How does the controller know which view to return?" I responded, "That's what I'm trying to figure out." I was trying to get the method to return a different view (or Json output) when AJAX was the requester. A string argument in the method was my solution.

This is what I ended up using to get my desired effect:

public ActionResult Index(string isJSON = "no")
{

/// ...All the code from before...[code]....

Then, when I want the JSON version, in my AJAX request I specify the URL as /MyController/Index/?isJSON=yes When I want my pretty table view, I just use /MyController/

View 2 Replies

Multiplie 2 Session Items?

Oct 9, 2010

I have made a small shopping cart, and i need to multiplie the Amounts of the various items with the price. And display the overall price.

View 2 Replies

Added 5 Views In The MultiView But All Views Are Tight Together?

Sep 28, 2010

I am learning MultiView control.Here are question:I added 5 views in the MultiView but all views are tight together. I can not drag and drop another control such as text boxes or labels into view area.

View 15 Replies

C# - .NET MVC Partial Views And Routing - Using Ajax Calls To Trigger A New Request But Non Of The Partial Views Are Refreshed

Mar 9, 2010

I have an MVC view that contains a number of partial views. These partial views are populated using partial requests so the controller for the view itself doesn't pass any data to them. Is it possible to reload the data in one of those partial views if an action was triggered in another? For example, one partial view has a jqGrid and I want to refresh the data in another partial view when a user selects a new row in this grid. Is there a code example for this scenario (in C#) that I can look at to see what am I doing wrong? I am using ajax calls to trigger a new request but non of the partial views are refreshed so I am not sure if the issue is with the routing, the controller,

View 1 Replies

MVC :: Why Synchronous Action Wasn't Executed Until Asynchronous Action Completed

Nov 29, 2010

I'm implement Comet in Asp.net MVC, I used timer to keep Async request in server, Async request will complete when timer elapsed 1 minute and response to client (to avoid 404 error) and then reconnect to Async Controller. I also wanna execute some Synchronous action during Async request was holding, but the problem is: When an Async action was executed and hold by using timer, the Sync Action wasn't called until Async action (comet long-live request) completed. I did test with firefox 3.6 many times, but the result is the same, so strange, Do you know why ? I have a sub some questions : To implement comet, using timer (response after some minutes elapsed) or thread (response after several time sleeping thread) to hold async request, which is better?

View 1 Replies

MVC :: Redirect Action Not Working In Jqgrid Action Results Method

Mar 23, 2011

I am desiging a master and details page from a search page..user can search for something and I need to display the result in jqgrid if the result has more than 1 row or record.. if the result is just one record then i have to directly send then to details page by skiping grid page... I do have an action method for results page and one more action method for Jqgrid data..i am trying to check the row count for the database result and trying to redirect to details action results..but its not working at all..and showing an empty jqgrid..

[Code]....

View 9 Replies

Test That A Controller Action Simply Returns A Link To Another Action?

Apr 29, 2010

Lets say I have a simple controller for ASP.NET MVC I want to test. I want to test that a controller action (Foo, in this case) simply returns a link to another action (Bar, in this case).How would you test TestController.Foo? (either the first or second link)

My implementation has the same link twice. One passes the url throw ViewData[]. This seems more testable to me, as I can check the ViewData collection returned from Foo(). Even this way though, I don't know how to validate the url itself without making dependencies on routing.The controller:

public class TestController : Controller
{
public ActionResult Foo()[code].....

View 1 Replies

MVC :: Create Action Not Carrying Model Across To Http Action

Jun 12, 2010

My httppost action doesnt seem to have received my model. The code is below;

[Code]....

i put a breakpoint on the line; return RedirectToAction("Error", "Dashboard"); and i found that appQualif carried no values whatsoever from the form i submitted..

View 5 Replies

How To Pass Parameters To An Action Using Html.Action() In MVC?

Jun 30, 2010

I've been using Html.Action("ActionName", "ControllerName") to invoke child actions across controllers without needing to have the view in ViewsShared. This has been working great for displaying things like session or cookie information.

Instead of just accessing cookies, I would like to pass additional parameters to Html.Action("ActionName", "ControllerName") so the action can execute different code based on the the data passed to the original view.

Should I be using a different method to pass parameters to a child action in a different controller?

View 1 Replies

MVC :: Controller Invokes GET Action Instead Of POST Action

May 20, 2010

I'm trying to add file upload functionality to a page. I've got a form that posts the selected file to a controller with a 'savefile' method. But if I don't add a get version of 'savefile' I'll get a 404 error. Here is the form code which is presented on the Index page:

[Code]....

And here is the controller code:

[Code]....

Intuitively I don't think I should need a GET version of SaveFile but if omit it I get a 404 error when the form posts. Why should I need a GET version of SaveFile when all I want is to post a form and save the file?

View 4 Replies

MVC :: Dynamically Adding Action Filter To Action?

Jun 21, 2010

Does any one know how to dynamically add ActionFilter to an Action?

View 3 Replies

MVC :: Determine Which Action Invoked Particular Action?

Nov 12, 2010

I have a controller with a bunch of actions as such:

[Code]....

I'm looking for a way to find out which action invoked the other: for instance, when redirecting to Action1, I need to know whether it is coming from clicking "next" button at Action0 or clicking "back" button at Action2. This is is to avoid performing Action1 twice (My app is like a wizard, if I click back button at Action2, I don't want to execute Action1 again).

View 1 Replies

How To Tell Create Button To Send To An Action Named Create And To Edit To An Action

Mar 14, 2010

I'm a newbie into MVC and I am like only on chapter 7 in ASP.NET MVC Unleashed so be easy with m

[Code]....

how do I tell Create Button to send to an Action named Create and to Edit to an Action named Edit on the same form?I guess it is possible on ASP.NET MVC if it is possible on ASP.NET Webforms

View 6 Replies

Partial Views / How To Implement Partial Views

Jun 16, 2010

i want to implement partial views in asp.net

View 1 Replies

MVC :: How To Call One Action From Another Action

Mar 31, 2010

I have a view MemberProfile like this

<% using (Html.BeginForm()
)
{ %>
<fieldset>
<p>FirstName :<%=Html.TextBox("FirstName", Model.FirstName) %></p>
<p>Last Name : <%=Html.TextBox("LastName", Model.LastName)%></p>
[code]...

View 1 Replies

MVC :: How To Redirect From Action To Another Action

Feb 3, 2011

I have a page with three partial views. On the first ascx, I want some data posted when a user clicks on "submit" button, and send that data to another POST action "search" and search the db with that data, the final output should be the view returned by "search". How do I do this?

View 3 Replies

MVC :: Action Method Returning An ActionResult Used In A Action Method?

Aug 27, 2010

I have the Index action method calling a method that itself is an action method.

Example :

[Code]....

What to do in this case ?

View 10 Replies

How To Use Partial Views

Jun 17, 2010

I have done partial views in ASP.NET MVC but now I want to convert it to ASP.NET. I have used AJAX and JavaScript. How can I convert the following:

<a href="#" onclick="LoadPartialView('#MainContentDiv', '<%=Url.Action("AdminHome", "Admin")%>')">Home</a> ,
<input type="button" value="Submit" onclick="LoadPartialViewPost('#MainContentDiv', '<%=Url.Action("ViewPage", "Controller")%>', $('form').serialize())" />

to ASP.NET, or in other words, how can I load a partial view in ASP.NET?

View 1 Replies

MVC :: Can't Use L2E Join In Views

Jun 29, 2010

[Code]....

i already can't view with select new{} tags but i continued to try.

when i adding a new view, i selected PLAYER table then i wrote this code to view:

[Code]....

i guess i can do this with "sql view" but i can't create view tables for everything.

View 5 Replies

MVC :: Change URL Of Views?

Nov 2, 2010

How do you change the URL of views for example if I have the following:

/Views/Home/Details.aspx will produce the following URL: /Home/Details/1

I would like to rename it to say News. I remember it being something along the lines of ActionResult but can't remember exactly.

View 9 Replies

MVC :: How To Use C# Classes In To Vb.net Views

Jan 29, 2010

I found datetimepicker class in one project . i.e C# project , in this project he/she created one class named as datetimeextensions.cs.

so then he/she imported in to one view and used like this .

[Code]....

i added this class in to my project and i tried to import but it doesn't appear in extensions?

View 4 Replies

MVC :: Using Namespaces In Razor Views?

Jan 18, 2011

I've recently switched over to using the Razor view engine, and I want to specify a namespace to use in a view. I've tried adding an entry to the Web.config file, ie:

[Code]....

But none of my views recognise any of the classes inside that namespace, so I have to declare the namespace in every view that needs it. why the Web.config approach isn't working?

View 13 Replies

SQL Server :: How Many Types Of Views

Jul 22, 2010

what is views how many types of views , why we used views.

View 5 Replies

MVC :: How To Set Viewdata As Global To Be Used By All Other Views

Dec 31, 2010

My doubt is i have two tables with Id as (Primary key) in one table and in the next table i have a Category Id field as Foreign key relationship with the 1st tabl Id field...

I have created a create view for the 1st table.My question is i have created a partial view for the 2nd table,but i need to pass the Id value to the second tables category Id field...So is there any way to do it by using Viewdata?

View 3 Replies







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