MVC :: PartialView Outside Of Form - ViewData

Mar 16, 2011

I have a little MVC 3 challenge that I am trying to overcome.Here is my scenario:I have a controller called PersonController.cs with 5 methods:Add Add (post) Edit Edit (post) PopulateName(string EmailAddress) - POST

I have a viewdata class called PersonViewData.cs with 3 pieces of data:

Email FirstName LastName

I have 2 PageViews (Edit.aspx and Add.aspx)I have 1 PartialView (Details.ascx) - with 3 textboxes (Name, Email, Phone)I want to reuse this partial view in both the Edit.aspx and Add.aspx Views.

The user should NOT enter the First Name/Last Name - rather, once the user has entered the email address (OnChange of Email textbox), the First Name/ Last Name of person should be populated. This is done using the PopulateName(string EmailAddress) controller method. Meaning, I have an AJAX Form inside the partial view

Then once all 3 fields are populated. The user should be able to submit either the Add or Edit HtmlForm.

Code of Edit.aspx:
[Code]....

Code of Add.aspx:
[Code]....

The main issue is as follows:I have an AJAX Form inside the partial view. Since now we have a PageView Form and nested PartialView AjaxForm - Form within a Form - the Browser has a hard time with this concept. In fact, when a person enters an email address, the frmEdit/frmAdd gets submitted.

View 5 Replies


Similar Messages:

MVC :: Showing Data By ViewData On PartialView

Mar 21, 2010

i am using this code that returns data form 3 tables

[Code]....

and i have a PartialView that will show the data.so how can i show the data in a foreach on my PartialView

View 5 Replies

How To Access ViewData In A PartialView From JQuery In MVC?

Dec 29, 2010

I have a View loading a PartialView via jQuery. The PartialView has ViewData that the jQuery needs to access, but I can't seem to get to it from the jQuery. The code below uses the HighChart jQuery plugin (and it is just test code taken from the HighChart example page):

<script type="text/javascript">
var chart1; // globally available [Code]....

This jQuery is in the main view, because I don't know how I could put it in the PartialView with the document ready function. But by putting the call to the HighChart function in the callback of the get() function it works in the partial view. But accessing the ViewData doesn't...

How can I achieve this? I need to get the data from the PartialView action method in order to populate the HighChart data...

View 1 Replies

ASP.NET MVC 2 - POST Form Model From PartialView?

Mar 1, 2010

I have a single model type to wrap up various models I want to use in my view:

public class QuestionViewData {
public Question Question { get; set; }
public IList<Answer> Answers { get; set; }
}

Now, in my question view I pull the data from the Question object - that's fine. Secondly I iterate through all Answer objects and pass them to a partial view:

<% foreach(Answer item in Model.Answers) { %>
<% Html.RenderPartial("ShowAnswer", item); %>
<% } %>

For each answer (in the partial view) I have some action buttons (like ratings). I'm using separate form POST's with hidden fields for every button. The problem is that I can't post the whole QuestionViewData model to my action method cause I only have the Answer object as model in the partial view. However, I need to return the complete question view from that action that takes QuestionViewData as model.

View 2 Replies

The Use Of PartialView In MVC?

Apr 7, 2010

Just I am learning MVC,(ofcourse i get enough information from MS Website).I want to quickly clarify some details.

1) What is the use of PartialView in MVC,Is it similar to partial update of Ajax? I am does the partialView modify the HTML DOM structure?

2)Can i use Response.Redirect() in MVC?

View 3 Replies

MVC :: PartialView With AutoRefresh

Nov 22, 2010

need to keep a list of logged users STATUSES at the Server level (either "ONLINE" or "OFFLINE").

so I wrote a Partial View to maintain the user current Status (Online, Offline). The server stores these values both on the Database and all the current Online users also in a Cached entry so that I can retrieve the list of all current "Online" users from cache.

In order to keep this list uptodate, I now need an asynchronous AutoRefresh call that notifies the server to keep my userID on the ONLINE list. This call should execute every xx seconds and should only execute if the current status is ONLINE.

QUESTIONS: 1) How can I create an AutoRefresh call that fires every XX seconds 2) How can I ensure this call executes only when I'm in ONLINE status

View 2 Replies

UserControl Or PartialView Using .net MVC 3 Razor?

Mar 15, 2011

I would like to display 3 three userControls on a home view

UserControl1 ==> Enterprise Entity partial view

UserControl2 ==> Client Entity partial view

UserControl3 ==> Biling Entity partial view

A submit button to save all values

So my home will display the 3 partial views and enable me; when I click submit button ;
to save Enterprise Data, Client Data and Biling Data.

View 1 Replies

C# - How To Change PageTitle From PartialView In Mvc

Mar 6, 2011

I want to change Page title from partial view. But following error shown

Using the Title property of Page requires a header control on the page. (e.g. <head runat="server" />).

My master page head section is here

<head runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
</head>

My Default page is here

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<%=ViewData["pagetitle"] %>
</asp:Content>

ViewData["pagetitle"] returns current page title for example Home, About, News List, News Detail. But i want to change current news information title instead of News Detail string. News Detail page contains partial view. Partial view know which news shown.

View 1 Replies

MVC :: Validation Clashing With Partialview - Remedy?

Feb 1, 2011

I have a view that is used as a search screen for a client database. I wanted to carry out the search using AJAX so the page would update smoothly. However, now the AJAX and PartialView are working, when validation is triggered by leaving both search fields empty, the reposted view appears inside the PartialView DIV ("Results"). The Page section looks like this:-

[Code]....

how I can stop the returned validation displaying inside the PartialView?

View 3 Replies

Reload PartialView From JQuery In MVC 2 Application?

Dec 7, 2010

I'm trying to use jQuery to load a PartialView. It does this fine at the first loading of the page. But then I need to be able to reload the PartialView when a save button is pressed. I get a reload, but this time the PartialView is all I get back. I.e. I don't get the PartialView loaded as a part of the main page, but rather as a page of its own. What am I doing wrong?

Here are the relevant parts of the jQuery in the View:

[code]....

View 1 Replies

MVC :: Calling PartialView From A Javascript Function?

Aug 2, 2010

how to call a partial view from within a Javascript function? I've looked around the web, but all the examples that I have been able to find are examples using Ajax.ActionLink or Ajax.BeginForm.

When a user clicks on an item, I want to be able to hide/display some Divs and possible do other operations before calling the partial view. ActionLink doesn't appear to provide that ability. Depending upon the item the user clicked, I may be assigning the results of the PartialView to the same Div, or to a different Div.

What I'm looking to achieve, is to have an onclick handler associated with the item which performs whatever other operations might need to be done, then assign the result of the call of the PartialView to the appropiate Div. In some instances, the function might even be making two separate calls to PartialViews, to update the content of two separate Divs.

View 1 Replies

Adding Jquery Functionality On PartialView Load?

Apr 23, 2010

How can I attach jquery on an ASP.NET MVC partial load. I've a form rendered in a partial that has some jquery attached, but that code is not running at all

View 3 Replies

MVC :: EnableClientSideValidation In A PartialView (jQuery Tab) With A Ajax.BeginForm?

Oct 14, 2010

I got a problem with client side validation not firing, after reading many posts I believe it as to do with the HTML being loaded "afterwards". But I can not seem to find any solution.You got any ideas how to solve it?

[Code]....

[Code]....

[Code]....

View 1 Replies

MVC :: Access Partialview Hidden Column In Main View?

Jan 11, 2010

how to access Partialview Hidden column in Main View(in ASp.net Mvc App)

View 2 Replies

MVC :: Ajax.BeginForm Not Displaying PartialView Always Redirects To New Page?

Feb 9, 2011

I have a very simple app where a user enters 2 text values and presses a button, I want a confirmation message to be displayed on the same page however it keeps redirecting to show the partial view as a full view.

This is my home View:

[Code]....

This is my ContactController:

[Code]....

And finally this is my Confirmation PartialView

[Code]....

This is using MVC 3/.Net 4, I have downloaded an MVC 2/.Net3.5 sample project from the web that is doing exactly the same which works fine. What am I doing wrong?

View 7 Replies

Pass Value Of Id Which Is In ViewData?

Apr 27, 2010

<%#ViewData["id"] %>
<h2>MarkerDetail</h2>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$.ajax({
url:"/Marker/MarkerDetailPartial",
data:"",
success:function(result){
$("#ReplyDetails").html(result);
},
error:function(result){
}
});
});
</script>
<div id="ReplyDetails">
</div>

& i want to send Id only By this Ajax

View 1 Replies

MVC :: Access To The First Data Of ViewData

May 3, 2010

i need to show project information by value of dropdownlist.by using this code i get a list of data to drop down list.now how can i access the first data in ViewData(or record)

[Code]....

View 5 Replies

Creating Dropdownlist From ViewData

Jul 22, 2010

Does anyone have any idea why the code below doesn't give me any value but instead gives me "System.Web.Mvc.SelectListItem"? If I don't do a foreach but instead substitute the ViewData with this

<%= Html.DropDownList("PersonOnCallCheckBoxList") %>, I get the correct value.
foreach (var person in ViewData["Person"] as IEnumerable)
{
%>
<input type="checkbox" value="<%= person %>" /><%= person %><br />
<%
}

View 2 Replies

C# - Difference Between ViewData And ViewModel

Mar 3, 2011

I'm new to .Net development, and now are following NerdDinner tutorial. Just wondering if any of you would be able to tell me What is the differences between ViewData and ViewModel(all I know is they are used to pass some form of data from controller to view) and perhaps tell me on what situation should I use ViewData instead of ViewModel and vice versa

View 1 Replies

MVC :: Add Multiple Values To Viewdata

May 27, 2010

I have one ActionResult method

[Code]....

This ActionResult is executed multiple time accoording the number user selected from previous page..each and every student id and StudentType is passed by that view to this ActionResult. my question is there any way that in ViewData we can store all these id's and studentType's so that I can use these id' and StudentType's in other ActionResult? bec I need only these two things in other ActionResult? I can implement this using cache but I dont want to do with that.

View 2 Replies

MVC ViewData Not Rendering In View

Jul 16, 2010

I have the following code in my post action method for Edit.

JobCardService.Update(viewData.JobCard);
var js = new JavaScriptSerializer();
ViewData["Notifications"] = js.Serialize(new {NoteificationType = "Success", Message = "The installtion was successfully updated"});
return RedirectToAction("Index");

However, on the client, ViewData is null/empty, i.e. this client code

var notifications = eval("<%= ViewData["Notifications"]%>");

renders as

var notifications = eval("");

I'm sure I'm doing something small wrong.

View 1 Replies

Mvc Viewdata Tempdata Variable?

Jul 29, 2010

tempdata variables works like a session variables?

basically i want to do is to when the form loads for the first time the variables should be empty. but the variable should be persisted until i am on that form.

the form contains searching with a submit button as well as the paging . basically my ques is to use what approach should i use?

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

MVC :: ViewData Value And JavaScript Function?

Feb 17, 2010

I am passing certain string value to a view using "ViewData" and I need to print the contents on a window which is rendered using Javascript. My question is how to pass this value to a window which is rendered using Window.Open ?

View 16 Replies

MVC :: Viewdata Is Defiant Null Always?

Apr 15, 2010

i return data to view by viewdata. and allways checking the viewdata for null but the viewdata is defiant null

this is my code for return data from database

[Code]....

View 1 Replies







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