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


Similar Messages:

Controller Method Not Always Called From $.getJSON Request?

Mar 9, 2010

I have a controller method that returns a jSON object and in one calling situation, it works and in another calling situation, it does not work. When the URL in my browser is this:

http://localhost:65247/Client -- it works.

But, when my url looks like this:

http://localhost:65247/Client/UserAdmin?id=6 -- it DOES NOT work

In a nutshell, clients have users. From within the client, I wish to work on a specific user (this is the UserAdmin view). In this case, the client id is 6. From within the UserAdmin view that was launched with Id=6, I then wish to select a user from a dropdown. The idea was to use javascript and $.getJSON to fetch data for the specific user so as not to have to refresh the entire page. I use this approach in other parts of the app. The only difference I can see is with the URL in the browser. It would appear the presence of parameters via the '?' is futzing things up a bit.

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

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

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

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

Javascript - How To Pass Json Collection Object To Mvc Controller Action Method

Dec 21, 2010

I am creating one Json array object and trying to pass it in MVC controller action method but i am getting null paramerter; as per my knowledge json only maps .net primitive datatypes.... so it assign null value.

Note: when i have look at request object i found that there are three parameter of created array. But how to get that value as parameter of function?

View 2 Replies

C# - Raise An Event Once When Reach End Of Method?

Jul 1, 2010

How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically? Lets say i have method called ClearFields(). I want to call the event before i hit the end of Clearfields() method.

View 4 Replies

MVC :: Routing Is Correct, But Parameters Don't Reach The Action Method.

Jul 1, 2010

I've been struggling for some time now with an MVC routing issue, but I have finally reached a point where the basic routing is correct; that is, the application is invoking the correct action method and .aspx page, but the action method fails because no parameters are passed to it.

Before I show detailed screenshots of the problem, I had better provide some background. This is a bibliographic application which, among other things, analyzes text abstracts to identify unique words and the number of occurrences for each word in each document. This data will eventually be inserted into a SQL Server database, but for the time being I only want to do the calculation and display the results, on a document-by-document basis, in an .ASPX view set up for the purpose. The data structure of the application is as follows:

Collections -this is a set of fifty or so CollectionDetails items.CollectionDetails represent individual documents, in this case books in an academic library. Attributes of the CollectionDetail record are those typical of a library book--author, call number, title, year, and so on. The title and subject catalog headings are combined to form a quasi-abstract, which becomes the basis of the text analysis. In a few cases, I added additional text from Google Books or Amazon synopses and reviews.

MasterStopList contains common words such as pronouns and prepositions that we want to exclude from consideration.

View 8 Replies

Error While Adding Dynamic Data To An Existing Web Site - The Method 'Skip' Is Only Supported For Sorted Input In LINQ To Entities. The Method 'OrderBy' Must Be Called Before The Method 'Skip'.

Apr 13, 2010

I am creating an Asp.net web site which will support dynamic data. When I am creating a dynamic web site from Scratch (from template in VS) all is working fine. But when I am trying to add dynamic entity (.edmx) file and running the application I am getting following error

"The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. "

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

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 :: How To Check In Controller Where The Maproute It Was Called

Nov 29, 2010

This two maproute maps to the same controller, how to check in the controller which maproute it was called from?

routes.MapRoute( _
"Categories", _
"category/15", _

[code]...

View 5 Replies

MVC :: Controller Not Called From Actionlink Or RedirectToAction

Mar 4, 2011

I am new to MVC2 and have hit a wall. When I use an action link to jump back to a previous page that I have already been on, my controller is not called but the page is rendered correctly. Is this some sort of caching that I am not aware of? This also happens with a RedirectToAction call from another Controller. rfm is the Model...

return RedirectToAction("Search", rfm);

Here is the actionlink...

<%: Html.ActionLink("Search", "Search", "Reference")%>

View 3 Replies

Javascript - Reach DataKey Cells Of GridView On The Client-side?

Mar 11, 2011

I need to reach DataKey columns of a GridView on the client side by a javaScript function.

As they they are at least visually disabled on the UI I wonder if I can still reach them on client?

View 1 Replies

.NET MVC Controller FileContent ActionResult Called From JQuery?

Feb 10, 2010

I have a controller method "SaveFile" that attempts to download a binary stream to client's PC using the FileContentResult. If I make the call as a post from the controller corresponding view everything works OK. I want to call the same controller method "SaveFile" from a jquery function via an .ajax call, when I do the function returns an error and the responseText is the contents of the file to be written. What would I have to do to get the same behavior from a jQuery function as if the MVC framework handled the call via the submit button? Or an alternate solution would be to determine how can I catch the browser's download dialog close event.

View 1 Replies

MVC ::Session Variables Called From The Owning Controller?

Feb 19, 2011

I'm calling an action from another controller using this code

[Code]....

But inside "ApproveOperation" action, I needed the Session variables. It seems when I called it from another controller (not the owning controller), the Session variables can not be accessed (null value).How can I get the same Session variables just like it was called from the owning controller?

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

MVC :: Controller Base Class Initialize() And OnActionExecuting() Not Called When Unit Testing?

Nov 16, 2010

I'm using a simple base class for my controller that sets a piece of ViewData and makes use of the HttpContext. My understanding is that I need to put this code in Initialize() or OnActionExecuting(). I tried both, but believe Initialize() is what I want.

This works when running the app in VS just fine.

I wrote a unit test that calls the action and checks the ViewData for the expected value. When unit testing, neither method is called.

View 2 Replies

MVC :: Create A Class Library Contains A Controller Based On Its Module?

Feb 22, 2011

In My Project I want to Create a Class Library Contains a Controller based on its module, Example : Class.Controllers.Album,Class.Controller.Artist

in this Class Library I wrote two Controllers AlbumController.cs, ArtistController.cs.When I add this to Main Project Contains Views,

View 1 Replies

How To Get A Listbox To Update After The Add Method Is Called

Mar 10, 2010

I am having a problem with getting a listbox to update after the add method is called. I am using an AsyncFileUpload control and as part of the AsyncFileUpload1_UploadedComplete I am creating a listItem and then adding that to the listbox. The item will not appear in the listbox. I have tried putting the listbox in an update panel and then calling the Update method on the panel from within the AsyncFileUpload1_UploadedComplete procedure and that too fails to update the listbox. I can call the Update method on the panel from a separate procedure and still the listbox will not update with the item added in the AsyncFileUpload1_UploadedComplete method.

View 6 Replies

JQuery :: AjaxStop() Method Is Not Called?

Jul 2, 2010

Below is my code, where the ajaxStop() method is not called.

[Code]....
[Code]....

View 1 Replies







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