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


Similar Messages:

MVC :: Calling Controller Action Using Jquery Post Ajax Call Abondons Session?

Apr 9, 2010

i have a website where i provicde a link. On clicking the link a controller action method is called to generate a zip file after creation of zip file is done, i show the link to download the zip file by replacing the link to create a zip with the link to download the zip.

the problem is that after zip file creation is over and link is shown, when user clicks on the link to download the zip file, they are sent to login. After providing correct credentials in the login page they are prompted to download the zip file. they sould not be sent to the login page. In the action to generate zip file i haven't abondoned the session or haven't not done anything that abondons the session.

the user should not be sen't to login page after successful creation of zip file user should be able to download the file without login. i search internet on this problem, but i did not find any solution. In one of the blog written by hanselman i found this statement that creates the problem with the session: Is some other thing like an Ajax call or IE's Content Advisor simultaneously hitting the default page or login page and causing a race condition that calls Session.Abandon? (It's happened before!)

so i thought there might be some problem with ajax call that causes the session to expire, but i don't know what is happening? it's like this after users click on the link to create zip file the zip file is created successfully but the session gets expired. this is not what i want. Why does the session has to get expired after making a jquery post call to controller action to create a zip file? i hope u understand the problem.

View 5 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 :: Call And Action / Controller From Inside Jquery?

Nov 17, 2010

How do I call and action/controller from inside a jquery function?

View 3 Replies

MVC :: Posting List Of Checked Items To Controller Action Using JQuery Post?

Feb 16, 2011

I got a list of checkboxes on my form, and a jquery script that catch a button click to get all the selected items (in an array) and post to a controller action.

This is my script: (yes A, looked at your sample but cannot get this to work)

[Code]....

That alert will print out correctly (like 1,3,5).

However when the above post hit my controller action, "selectedInvestments" are null, which I can't figure out why (back to my tekpub jquery videos, can't go on like this)

[Code]....

View 3 Replies

MVC :: To Call Non Ajax HttpGet Controller Action Via Jquery

Jul 6, 2010

i would like to call an HttpGet GetEvents(Datetime dateSelected) controller action each time the user cliks on a date in jquery ui datepicker. I handle the onSelect datepicker event in order to call GetEvents() and refresh the Events page with the events for the selected date. The $.ajax method i use from jquery hits the GetEvents action, but instead of refreshing the page (and the url), i get an ajax result back.

[Code]....

So, how could i just call the HttpGet GetEvents() controller action via jquery, without the use of ajax in order to refresh the page?

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

Can Call A Webservice From A Controller Action In MVC

Oct 27, 2010

Can I call a webservice from a Controller Action in ASP.Net MVC?

public ActionResult Index()
{
PersonObject person = new Person("Sam");
//Call a webservice which is located in the same app under /Services/General.asmx/WebMethod and pass it person
}

Basically I want to do this from my Action...

$.ajax({
type: "POST",
url: "/Services/General.asmx/WebMethod",
data: JSON.stringify(DTOInternetPricing),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(res) {
},
error: function(res) {
}
});

View 2 Replies

MVC :: HTML Submit Button - How To Call Controller Action

Aug 12, 2010

In the view I have a HTML button:

<input type="submit" value="Submit" />

Also I have a dropdownlist, how do I call the controller's action after I click the "Submit" button?

And how do I pass the Model back to the controller action as well?

The reason I want to pass back the model (or other object/class) to controller's action is I might have 5 dropdown lists and 3 edit boxes values to be sent as parameters. So I would like to assign these parameters into a object and send it back to controller's action.

View 11 Replies

MVC :: How To Call Action In Controller On Input Submit In HTML Page

Jul 13, 2010

I am quite new to MVC development and facing some basic issues.

I am having a form on which I am taking input form user. It is bould to one of the properties on Model class.

I am having a submit button

<input type="submit" value="Save"/>

Now I want to call Save Action in my controller on click on this Save button.

But it is not working. I have checked on following things:

1. My HTML page is correctly point to the controller

2. I have written HTML code as

<%= HTML.BeginForm("Save","ControllerName", FormMethod.Post); %>
<input type="submit" value="Save"/>
<%= HTML.EndForm();%>

View 5 Replies

MVC :: How To Call Action Method Of Controller After Dropdownlist Selection Changed

Jan 1, 2010

I know we can set autopostback property of dropdwonlist using javascript or jquery and it will go to action controller specified in Form tag.

[Code]....

but how can we set it to some different action other then what we specified in Form Tag.

View 3 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 :: Use JQuery To Get Controller Action?

Oct 19, 2010

I have this action on below

public ActionResult Edit(int id)
{
var mtn0120 = __context.GetMtn0120(id);

[code]...

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

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

Jquery - Get Json Data In Controller Action?

Feb 9, 2011

I have asp.net mvc application. i want to configure the object in jquery and want to pass it to the the action of controller . where as in my script i am using this for configure data for the ajax call:

[Code]....

it does not calls to action in controller. i think here :

var json = $.toJSON(peform);

is not working as expect. is it need to add any js file to reference ? or mistake in syntax?

View 1 Replies

MVC :: Post Data From View To Controller?

Mar 24, 2010

I'm a php programmer (code igniter) but interested in learning ASP.net MVC, I have a few question regarding this new exciting framework In php codeigniter's controller I can easily catch a post variable using

[Code]....

In comparison in ASP.net MVC we can create an action method that will accept post variable (but the parameter can get very crowded if we're passing a lot)

[Code]....

Or using FormCollection

[Code]....

Is there a way to catch post variable in ASP.net that looks like php's codeigniter? I mean not by adding the parameter, because I wanted a controller method that is flexible in receiving post request A controller that can accept and process any post request like in php (where we don't have to put that parameter to the controller method, we just call them

[Code]....

View 3 Replies

Passing Form Data To Mvc Controller Action Using JQuery?

Feb 3, 2010

Basically, I have an HTML Form and would want to pass the data from the form to n asp.net mvc controller, then the controller would return an XML for client side manipulation.

Here is my initial code:

[Code]....

When I run and debug, I get a message that says "attr(..) is null or not an object. I am still trying to learn web development using ASP.NET MVC.

View 3 Replies

MVC :: JQuery Post To An Action Method?

Oct 19, 2010

I'm trying to use the jQuery.post() function to post an object to an action method, but for some reason the nested objects aren't initialised properly when they're received by the action method.

Here's my javascript code:

[Code]....

And my action method:

[Code]....

company.Id has a value of 10, but company.User.Id is 0. what I'm doing wrong? I've not named any properties incorrectly, by the way.

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

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

JQuery Ajax With MVC Action - Passing Arguments From JavaScript In POST

Mar 4, 2011

I have an ASP.NET MVC controller action with the following VB.NET signature:

<HttpPost()>
Public Function ClosestCities
(ByVal position As MapCoordinate, ByVal citiesCount As UInteger) As JsonResult

The MapCordinate class is:

Public Class MapCoordinate
Public Latitude As Double
Public Longitude As Double
End Class

If I'm trying to send an Ajax POST in jQuery to the ClosestCities action, what should my request look like?

When I use the following code to POST to this action, in the debugger window of VS, position.longitiude and position.latitude are equal to 0.0 (0D):

[code]....

View 2 Replies

MVC :: Securing Action From JQuery Call?

May 28, 2010

How to secure an Action filtered with Authorize method from a jQuery call? I have this Authorize filter and it work's cause users are redirected if not logged-in. But after logging-out then accessing previous open pages that needs authorization, they weren't redirected at all. This jQuery is initialize when a button is clicked,

jQuery.post(
"/controllername/IsUserActive", {
}, function (data) {
if (data){
$('#div_user_active').html(data);
{ else {
$('#div_user_active').html('Not Active');
}
}
);

then calls this Action method.

<Authorize()> _
Function IsUserActive() As Boolean
Return True '<<---this keeps returning even users are already logged-out.
End Function

Overall, I wanted ajax(jQuery) to update/read a portion of the page but gets redirected if not authorized.

View 1 Replies

MVC :: Post Strongly Typed Partial View's Data To It's Parrent's Controller

Mar 3, 2011

I'm gonna create profile page for my site. This page includes some 'Partial View' and each part posts some data.

My question is: How can I get posted data (strongly typed) from each partial view separately? Something like this:

[HttpPost]

public ActionResult Home(Model1 model1, Model2 model2, ...)

{
return View();

}

View 4 Replies







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