Primary Key In A Partial View Shared By Create And Edit Views

Jul 13, 2010

I have a partial view (user control) that is shared by my Create and Edit views. When I use it in the Edit view, I have to to include an hidden field (Html.HiddenFor) to prevent a 'Row changed or not found' error in my data service, but when I use it in the Create view, I have to remove the PK hidden field, to prevent an error over trying to insert into an identity column. It is not feasible to not use identity columns in this application, so how can I 'switch' that PK hidden field on or off depending on which action has been invoked?

Post Action Code:

[HttpPost]
public ActionResult Edit(JobCardViewData viewData)
{
try
{
jobCardService.Update(viewData.JobCard);
Edit View Excerpt:
<% Html.RenderPartial("JobCardInput", Model); %>
Partial Excerpt:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Poynting.Installation.Web.ViewData.JobCardViewData>" %>
<% using (Html.BeginForm())

View 2 Replies


Similar Messages:

MVC :: Create Partial Views In View?

Feb 22, 2011

I want a view that contains 2 partialviews. 1 partial view should be a create or edit view (of items) and in the second partial view there should be a list with the items that are created (and which can be edited). When an item in the list is selected for editing the 1st partial view should show the edit view with the item to be edited.

After saving the data, the create view should be shown in the 1st partial view again. When the view comes up for the first time the 1st partialview should contain the create view. In normal ASP.net I would do this with a formview (with insert and edit mode based on the itemselected in the gridview) and a gridview (and of course everything in an AJAX update panel).

View 2 Replies

MVC :: Create View With Partial Views But Submit Button Doesn't Work

Jan 11, 2011

i created a "create" view for creating a new record of my used model. The View includes partial views with the editor-fields. But the "Create" submit button doesn't work. When i copy the editor-fields to the create view without using partial views the submit button works. Here is my code: Create.cshtml

[Code]....

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

How To Create Shared Views In MVC

Jan 20, 2011

In my Views folder I have a several folders such as Category, Origin, Price. They all have a Browse.aspx file and the code in this file displays a table of products. All controllers associated with these folders use the same ViewModel, but in each view I have a repetitive code. The code is:

Folder Category, file browse.aspx
Folder Origin, file browse.aspx
.....

<% foreach ( var p in Model.Products) { %>
<li> <%: p.productname + " " + p.price + " " + p.origin.originname + " " + p.category.categoryname %> </li>
<% } %>

How can I create a shared view and use the shared view in all these views?

View 1 Replies

MVC :: Handling Primary Key Field When Creating An Edit View (using Add View Dialog)?

Apr 7, 2010

When using the "add view" dialog in vwd is there a common practice for presenting any primary key fields as readonly to the user in the view?

By default it appears the user could change the key field value (as it is presented in a textbox) and overwrite data for that record for which the key was accidentally changed to.

Do we have to store the original record's key and then make the key presented as a label and then on the update subtitute the original key value back in for the record? Or is there something simpler?

View 3 Replies

MVC :: Trying To Get The Current Nameof The Controller Within A Partial View (under /shared/)?

Dec 17, 2010

im trying to get the current nameof the controller within a partial view (under /shared/).

ViewContext.RouteData.Values["Controller"].ToString() worked well for me. But not with a partial view.

I call the partial view from /Admin/Details. But im getting /Admin/Details/Admin as result. Maybe this is a bug? Here is my code:

[Code]....

View 2 Replies

MVC :: Loading Partial Views Inside Containing View?

Mar 11, 2010

I have a Controller set up for a certain View. This View contains 2 partial Views (ascx files). Each partial View has a Controller method that yields its DataModel. The containing View doesn't currently display any data, but just serves as a container for the 2 partial Views.

Here's the problem: The Index action of the containing View runs, but the Controller methods for the partial Views don't, so I get a null exception when the Model tries to render out the data that should be available. I'm using MVC 1.0, which is something of a bummer, since it seems that the next version is supposed to have something other than "RenderPartial" that will assist with this very issue. However, since I'm stuck for the moment with 1.0, can anyone give some advice on getting the Controller methods to run for the partial Views?

View 1 Replies

MVC :: Use Mutliple Models For One View Or Partial Views?

May 8, 2010

I've recently began learning ASP.NET MVC.I created my first project, and added a model via Linq TO SQL. The first model handled a database table that held a list of menu items.I then created a view and the view would loop through all of the menu items returned by the controller and build a custom menu for me.

I then created a Model via Linq TO SQL to point to a table that hold's my site articles.I created a view that would itereate through all of the site articles returned by the controller and list them in the view.

Now I've taken the logic from the menu view and created a partial usercontrol view to build my menu. I've done the same thing with the SiteArticles.

How do I make the data from both of these modles availble in one view?I basically want to HTML.RenderPartial("MenuControl") in my master page and RenderPartial("ArticleControl") in the conent of the view.

I'm using the original view that i created to show articles..

So If i remove the rendering of the menucontrol user control from the master page and i call the view to show the articles, the articles will render because the controller knows to load the articles and return them to the view..

If i add the menu user control to the masterpage, I get an error because the view recieves data from the site article model/controller but not from the menu model/controller.

View 3 Replies

MVC :: Use Of Partial Views - Index Page Of A Normal View

Mar 25, 2011

I am using the following in the index page of a normal view.

Index
Index
User Listing

View 2 Replies

MVC :: Razor View Engine - How To Register The Partial Views In 3 Beta

Oct 15, 2010

On my projects I am using Razor View engine and I need to define custom Partial folders:

[Code]....

I had this because there was a problem in MVC 3 Preview. Was it corrected?

How should I register the Partial Views in MVC 3 Beta?

View 1 Replies

MVC :: How To Create Partial Views Using The Razor Engine

Jan 20, 2011

Using the Razor engine how do I create Partial Views. Do I create a normal View and calling the PartialView() in the controller will only output the body content and when calling View() in the controller will output the full page with layout. If not, do I need to create specific Partial Views and then use RenderPartial in the View.

View 6 Replies

MVC :: Finding Example For Passing Values To Partial Views (and Or To View Database Pictures)

Aug 11, 2010

I probally just tired but I would have swore I had seen an example of this some where for MVC 2,

I want to call a partial view that shows the products information with a GUID passed to the partial view.

I guess you would call it calling a sub but have that sub in a view that i can strongly wire up.

What i need is tutorials for passing a value to the partial view.

Like if i had pictures and i wanted to call a ascx that would show the picture. and have many to a page.

An example about pictures wired into a entities database would rock.....

I did try to look around on here to find some but my mind just gave out on me today....

View 1 Replies

MVC :: Checkboxes With 2 Create / Edit Views

Oct 25, 2010

I'm currently writing a game review site in MVC 2. I'm having some problems both figuring out exactly what to use as my view models and how to display checkboxes in my form for a many-to-many relationship. My main models generated by EF4.

The biggest problem at the moment is trying to figure out how to create checkboxes for a game's platforms. There's a many-to-many relationship between games and platforms - each game can be available on a number of platforms (PS3, XBox 360, etc.), and each platform has a library of games. In my Edit view, I need to list all of the platforms and have the ones the current game is listed for checked. I have the following view model:

[Code]....

So, I need to list all of the view model's Platforms while putting a check mark in the GameData's platforms.

View 1 Replies

MVC 3 - Razor - Trying To Use A Partial View For A File Upload In A Create View?

Oct 19, 2010

I am trying to use a partial view for a file upload in a Create View.

Here is my partial view, I removed the submit button, as the view it is rendered in, should activat the form post:

@model dynamic

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

Partial Views / How To Implement Partial Views

Jun 16, 2010

i want to implement partial views in asp.net

View 1 Replies

Can Create A Partial View And Pull It Into Another View

Feb 22, 2011

I'm rather liking this MVC3 and Razor way of working and I'm learning the ropes. I was wondering, can I create a partial view and pull it into another view in the following scenario:I have a "Person" model and an "Address" model. The Person contains name, phone number etc and each person has an address. I've created my Person "Create" view and that works fine but I now want to pull in my "Address" partial view to it.

View 10 Replies

How To Create A Helper That Is Going To Render A Partial View With A Model

Sep 15, 2010

I'll give a very simple example:

at the moment I have to write like this:

<% Html.RenderPartial("hello", new HelloInput { Name = "Jimmy" } ); %>

I would like to be able to like this:

<%=Html.Hello("Jimmy") %>

So I would like to know how create this helper:

public static string Hello(this HtmlHelper helper, string name)
{
return the result of rendering partial view "hello" with HelloInput{ Name = name };
}

View 1 Replies

MVC :: Cannot Assign Timespan Display Format Attribute On Create/Edit And Display Views

Jul 6, 2010

inside my model metadata, i have a timespan field that would like to display in all Create, Edit and Display views like "hh:mm". For this, is set DisplayFormatAttribute as follows:

[Code]....

When i try to create a new model object, the time field gets displayed as "00:00:00" im my model (00 is the initial values) instead of "00:00". Is there something i am doing wrong? Note that the same approach works for date fileds, where i want to be displayed as "dd/MM/yyyy" (for this is assign "{0:dd/MM/yyyy}" to the display format attribute).

View 4 Replies

DataSource Controls :: Using Views With EntityFramework Is Not Able To Recognize Primary Keys

May 2, 2010

Cannot seem to find a good fit for my question so I will ask here.

Does Asp.Net 4.0 solve the problems with using Views with EntityFramework is not able to recognize primary keys.

View 2 Replies

MVC :: How To Upload Image In Edit And Create View

Mar 3, 2011

I am creating a web application using ASP.Net 3.5 MVC , I have created Edit and Create views, one of the fields is Image URL,How can I upload a image in a web server folder and save the name of image in database (as a part of Edit and Create view)?

I have added following code in Create/Edit view:

[Code]....

View 5 Replies

MVC :: Tabular View Create And Edit Template?

May 18, 2010

Does anyone have a Tabular create and details MVC 2 Template that i can pop into my project and use, instead of the ugly linear templates that come out of the box in MVC?

Are there free MVC view templates anywhere on the internet?

View 3 Replies

MVC :: Default Edit Controls In 2 Create View?

Mar 21, 2010

i created a create view for an entity in my database using MVC 2 in VS2010.I noticed that the auto generated code used HTML.TextBoxFor for ALL the columns..this isnt very optimal.Is there a way to get it to use Html.DisplayFor ? I have a bit column that the auto generated code used a textbox for..How can change this using UIHint.

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







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