MVC :: Action Is Not Called From View?

Mar 8, 2011

Error:An item with the same key has already been added.

[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9382923

[code]...

View 7 Replies


Similar Messages:

MVC :: Action Is Not Called From View

Mar 9, 2011

Error:An item with the same key has already been added.

[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9382923
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +252
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer) +91
System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +228
System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +392
System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +147
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +98
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +2504.................................

View 2 Replies

Passing Value From Action Method To View From Where It Is Called

Mar 3, 2011

In one view (view1) there is a text box and a button beside it. i click on that button, i am popping another view (Create view) as a seperate window. in create view i am entering some values and creating a record in db. out of these values one value i have to send back to "View1". how can i send this value? i am opening view2 from view1 like

<input type="button" value="Get ID"
onclick="window.open('<%=Url.Action("Create","Controller1") %>',
'','scrollbars=yes,width=800,height=800,resizable=yes');"
/>

View2 contains some fields like Name,Email etc... and I click "Create" to call HTTPPOST. there i add the values to db including a generated guid. i want to send this ID to view1.

View 2 Replies

C# - Determine Which Tab An Action Was Called From?

Aug 27, 2010

The page I'm editing had three tabs, each tab contains a diffrent grid view which is populated by a search box with in the tab. Each row in the grid view has a check box. When a print button is pressed all records with a tick in the check box should be printed off. Then page then reloads but some of the content is missing due to the way the page has been coded. This is becuase some of the code is only called when the tab is clicked not on postback. Is there anyway that I change the following code so that it's called after postback? These are the functions that are causing the most problem.. I need them to be loaded for the correct tab on postback.. I can't do it for all three as the code takes forever to run in that case.

AddActionsToGridView(gvGlobal);
AddCheckboxesToGridView(gvGlobal);
{
if (tabconConsignments.ActiveTabIndex == 0)
{
dtGlobalIDConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "GlobalID", "", "");
//Global ID Tab
gvGlobal.DataSource = dtGlobalIDConsignments;
gvGlobal.DataBind();
//Actions
AddActionsToGridView(gvGlobal);
AddCheckboxesToGridView(gvGlobal);
}
else if (tabconConsignments.ActiveTabIndex == 1)
{
dtCreatedDateConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "CreatedDate", "", "");
//Created Date Tab
gvCreationDate.DataSource = dtCreatedDateConsignments;
gvCreationDate.DataBind();
tbCreationDateSearch.Text = "";
//Actions
AddActionsToGridView(gvCreationDate);
AddCheckboxesToGridView(gvCreationDate);
}
else if (tabconConsignments.ActiveTabIndex == 2)
{
dtAccountsConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "Account", "", "");
//Account Tab
gvAccount.DataSource = dtAccountsConsignments;
gvAccount.DataBind();
AddActionsToGridView(gvAccount);
AddCheckboxesToGridView(gvAccount);
}

if you want me to post any more code or any more info it's been a hard one for me to get my head around so I might of missed something out.

View 2 Replies

Button Click Handler Not Being Called Unless Form Action Is Specified?

Mar 9, 2011

I have a simple ASP.NET web application for data collecting (a webform with two text fields and a Telerik editor, a button for submit with server side OnClick event listener attached).The event listener saves data on DB and then redirects to another page.Under development web server the application works fine.When published under IIS7 the event listener doesn't fire. The only way i found to make it work is to specify the action on the form tag:

<form id="form1" action="default.aspx" runat="server">

This is the first time this happens to me, i never run into this problem before with other applications (even more complex!).

View 1 Replies

MVC :: Action Links Does Not Appear In Masterpager Design View Nor In View Page?

Mar 3, 2011

i am trying to but a menu of links in master page

but they does not appearr

here is the code

[Code]....

View 5 Replies

MVC :: Cascading Action For Multiple Partial View In One View?

Nov 1, 2010

I would like to create one view for my CRUD actions. The view contains 3 basic DIV updatetargets ("search form", "search result listing" and "action" (would be create,detail,edit,delete). Basic flow would be: "Search" updates the "Search Result Listing", click on CRUD actions in listing would show partial view in "action".

how do I call to refresh the "Listing" after I do any add/update/delete without having user click search again?

Index:

[Code]....

Result Listing:

[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 :: Using Action Filter With View?

Feb 9, 2011

I am trying to return different views with xml and json result when say -/API/Security/Authentication/login.xml is passed or

API/Security/Authentication/login.json is passed . I have adde mapped routes for this path.

I have used the ActionFilter attribute for the Login Action Result to automatically check for xml or json and then return the appropriate view.

what to put in the Login.aspx file to render appropriate xml or json based on the above url passed ?

The code is below:

[Code]....

View 2 Replies

C# - How To Get The Id From / Controller / Action / Id From Within A View Page

Sep 22, 2010

From inside a viewpage, how can I reference the id from the url /controller/action/id without getting this data from the model?

View 3 Replies

MVC :: Data From Action In Controller To View

Jan 19, 2011

So I have a dropdown in a form which when at item is selected postback to database and get some values which I am now storing in an object. I need to get the values from this object into textboxes on the form in the view..how can I do this???

View 2 Replies

MVC :: Pass Object From Action To View

Jan 20, 2011

I have the following action executed when a user selects an item from the dropdown;

[Code]....

The object paymentApplicationRefund is populated. I want to get the contents of this object to put in a Html.Textbox(). How do I proceed??

View 11 Replies

MVC :: Get Value Of A View's Selected RadioButton From A Controller Action?

Jul 15, 2010

I have a simple controller that sends a model/data to a View:

[Code]....

The View displays the data in a HTML Table:

[Code]....

This View displays the data correctly and provides a RadioButton for each row. When I select one of the RadioButtons the previous selection is removed as expected.

For now I am using an ActionLink to enter another Controller action. I have tried many ways without success to retrieve the selected RadioButton's value in this controller action.

[Code]....

I have also tried defining the Controller action with a parameter matching the model without success.

[Code]....

View 2 Replies

C# - How To Call A Javascript Method After Action Or From A View

Feb 12, 2010

i just want to be able to call a javascritp subroutine on the client, after the server has done its thing (when an action completes or control goes to the view, i'd dont mind calling the js from the view either).

for some reason, even vs2010 doesn't let me put breakpoints in <% ... %> tagged areas between <script...> and </script> tagged areas. i for this reason can't figure out whats going on and how it's running things. here is what i've put in my view, and the javascritp should run, but it doesn't....

im just trying to call "RunOnceRoutines;" but it's not getting called!

the 2 questions: how on earth do we call javascript methods from server, and where is all this lovely javascript debugging i've heard about since vs2008? no where to be found!

[Code]....

View 1 Replies

MVC :: Can't Call Different Controller On View Using Action Link?

Feb 8, 2010

I have one problem with actionlink. My Example is: i have one view(xyz.aspx) and controller(abc.vb) , in this view i put below line

<%=Html.ActionLink("Manage", "Index", "Advertisement", New With {.aintCampaignid = Cam.CampaignID})%>

I have another view(Index.aspx) and controller(Advertisement.vb) if click on manage link in XYZ view it will call to advertisement controller and index function But iam getting [URL] it wont call.

View 5 Replies

MVC :: Deleting A Controller Action And Its View In One Step?

Oct 20, 2010

Since a Controller Action and its View are associated with each other I would think that there would be a way to delete both in one step.

View 3 Replies

MVC :: View The Modelstate Errors In Action Method?

Oct 18, 2010

for debugging purposes, how do I see the ModelState errors from code in the action method? ModelState.IsValid returns false. I want to copy the error messages to a variable so I can display them in the debugger.

View 2 Replies

MVC :: Edit The Content Of A View From An Action Filter?

Jan 6, 2011

Is it possible to edit the content of a view from a action filter.

What I am working on is a Resourcemanager that I can use to manage

my style sheets, js and other resources. I want to be able to put

lines in the the view any where like Html.ResourceManager.AddScriptFile("MyScript")

or Html.ResourceManager.AddCSSFile("MyCSS")

and at the end of the view call Html.Render(); this would then place the content of my resources at this point. My problem is that I want to put the CSS stuff at the top of the view, but them problem is that it is renderend at the end of the view, so I tought that I could use a ActionFilter to move it to the top of the view.

1) What would be the best way to do this task ?

2) Is there any resources that describe the way that the MVC framework works in more detail ?

View 2 Replies

MVC :: Not Getting Values From View To Controllers Action Method?

Apr 21, 2010

When i try to insert values from textbox to db the values are not getting inside controllers action method.

My View Page codings

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MvcEntity.Models.Movie>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

[Code].....

System.ArgumentException: Value cannot be null or empty.

View 5 Replies

.net - Pass Int Value As Model To A View From An Action Method?

Sep 16, 2010

I am using ASP.NET MVC 1. I want to pass an int value to from an action to view. I can use 2 ways.

Use ViewData dictionary.
Define a class to contain the int value.

Other these two, Is there a way to pass the int value to view so that I can get the int value using just Model like

<label><%= Model %></label>

View 2 Replies

MVC :: How To Call Post Action Controller From View Using Jquery

May 12, 2010

ia ma working on an asp.net mvc 2 app and i have a Users view, displaying all the users of the database. Then, i would like to add the ablility to display "users starting with fisrt name" capabaility on the same view. For this i created a list of all english leters that actually are links (<a href="#">A</a>, etc...)

I managed to handle the click event of each one of the letters and get the corresponding letter via jquery, but i don't know how to call theHttp.Post Users/FindUserByFirstLetterName(string letter) on the click event.

I cannot use the Html.ActionLink<> helper, since it redirects me to the HttpGet controller action.

I also tried using using jqery.Post but i also couldn't manage to call the action.

View 7 Replies

MVC :: Deal With Dictionay Of View Model When Edit Action

Jun 3, 2010

I have a dictionary in my user's view model used to store user's roles:

[Code]....

In my edit view:

[Code]....

the code above generates:

[Code]....

It seems that when I edited the checkboxes' value and post to server, the UserEditViewModel.Roles is empty.

View 2 Replies

MVC :: Passing Json Collection Object From View To Action

Nov 1, 2010

I am trying to send json data from view to controller action. But the issue is the data is not populating in the action parameter List<Score>.

View Model:
public class Score
{
public int QuestionId { get; set; }
public int PrevAnswerId { get; set; }
public int CurrAnswerId { get; set; }
public string CurrAnswerName { get; set; }
}

Json Data look like:
[
{QuestionId:1, PrevAnswerId:3, CurrAnswerId:3, CurrAnswerName:'Known to Broker'},
{QuestionId:2, PrevAnswerId:7, CurrAnswerId:7, CurrAnswerName:'Completed'},
{QuestionId:3, PrevAnswerId:10, CurrAnswerId:10, CurrAnswerName:'Report'}
]

On window load, I will construct the Json object using "eval()" function and do some operation in the data before its save. On Save Click, I will call the action through the ajax call.

$.ajax({
url: url,
type: "GET",
dataType: 'json',
data: {score: ScoreJson},
contentType: "application/json; charset=utf-8",
success: function () {
alert("succes");
},
error: function () {
alert("error...");
} });

Action:
public ActionResult SaveScore(List<Score> score)
{
// do something...
}

But here score comming as collection of 3 elements with zero(for interger property)/null(for string property) values. When I checked in the request I found the data in "parama" property like.

"Score%5b0%5d%5bQuestionId%5d=1 &Score%5b0%5d%5bPrevAnswerId%5d=3 &Score%5b0%5d%5bCurrAnswerId%5d=3 &Score%5b0%5d%5bCurrAnswerName%5d=Known+to+broker&
Score%5b1%5d%5bQuestionId%5d=2 &Score%5b1%5d%5bPrevAnswerId%5d=7 &Score%5b1%5d%5bCurrAnswerId%5d=7 &Score%5b1%5d%5bCurrAnswerName%5d=Completed&
Score%5b2%5d%5bQuestionId%5d=3 &Score%5b2%5d%5bPrevAnswerId%5d=10 &Score%5b2%5d%5bCurrAnswerId%5d=10 &Score%5b2%5d%5bCurrAnswerName%5d=Travelers+Report&".

But I am not sure why it is not getting populated in the score list. One full day I spent for this issue but till now I didnt find the solution for this issue.

View 4 Replies

Ajax Update After Delete Action On Index View In ASP.MVC

Jul 14, 2010

I'm trying to do an Ajax delete in a fairly standard Index few, i.e. I have a generated Index view with one added filter drop-down, of little relevance here. I have changed the free Delete Html.ActionLink on every row to an Ajax.ActionLink, and the delete and ajax update work, but whichever container div I try and update, I always somehow get some kind of nesting in the updated page, e.g. after a delete and update, I get duplicate Home and About links from the master page inside my content. Here is my current action link that causes what I describe above:

<%: Ajax.ActionLink("Delete", "Delete", new { id = item.InstallationDBNumber }, new AjaxOptions { UpdateTargetId = "jobList" }) %>

... and here is where jobList is located, just outside the table used for the index list:

<div style="clear: both;">
</div>
<div id="jobList" class="index-list">
<table>
<tr>

View 1 Replies

MVC :: Partial View Contains A Link That Calls An Action Via Ajax?

Nov 27, 2010

I have a view that renders a few partial views. Each partial view contains a link that calls an action via ajax. The result from the action is used to fill a div. Because I use the same partial view a few times, it always renders the div with the same id. In asp.net, we have something like naming container, that assures that each element has unique ID. How can I make IDs in a partial view unique ?

View 1 Replies







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