Calling Action Method In MVC With JQuery And Parameters Not Working

Dec 27, 2010

I'm trying to call an action method in an MVC application using jQuery. Basically what I want is to take the value of a couple of input fields and call the action method by clicking a button, passing the values of the input fields as parameters. But I only get the value of the "number" parameter, not the "year" parameter.

function selectWeek() {
$('#selectWeekButton').click(function (event) {
var number = $("#selectWeekId").val();
[code]...

I checked the url with an alert, as you can see, and it seems to contain both values fine. But when I check the value of the year parameter in the action method it is null.Here are the input fields:

<span>Vecka: </span>
<input type="text" id="selectWeekId" />
<span>År: </span>
<input type="text" id="selectYearId" />
<input type="button" value="Välj vecka" id="selectWeekButton" />

And the beginning of the action method:

public ActionResult Edit(string number, string year)
//etc...

I know that this looks like a strange thing to do instead of just binding fields, but the reason is that these input fields and their values is not the main purpose of this View. They're just there to select another week in this timesheet application. And besides, I'm going to replace the input fields with a jQuery calendar eventually, so I will still have to do something like this.

So what's the easiest way to do this, and why isn't it working as it is?

View 2 Replies


Similar Messages:

MVC :: Redirect Action Not Working In Jqgrid Action Results Method

Mar 23, 2011

I am desiging a master and details page from a search page..user can search for something and I need to display the result in jqgrid if the result has more than 1 row or record.. if the result is just one record then i have to directly send then to details page by skiping grid page... I do have an action method for results page and one more action method for Jqgrid data..i am trying to check the row count for the database result and trying to redirect to details action results..but its not working at all..and showing an empty jqgrid..

[Code]....

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

MVC :: Making An Html Button Call An Action Method With Parameters?

Mar 10, 2011

how to make a stadard HTML button call an action method and pass parameters to it? Can you please show me an example of how to do this? THis is the method:

public ActionResult CCDReview([DefaultValue(1) int CUrrentPage])
{
//method code is here.
}

Yes, my button is wrapped in a form, and it's a "submit" button.

View 9 Replies

JQuery-AJAX Calling Page Method / How To Return Value Back To JQuery

Jan 31, 2011

If I use jQuery AJAX to call a specific ASP.NET page method how to have that method return a value back to the AJAX method that called it?

Update

My situation is I have an existing web application with many existing methods. I would like to be able to use jQuery to execute some of these methods and then update the UI with the results. My mandate is to stay away from ASP.NET AJAX and stick with jQuery. Management is concerned about continued development and support with ASP.NET AJAX from Microsoft. I agree with them.

View 3 Replies

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

JQuery Calling Webservices With Parameters And Getting Data Back?

Feb 25, 2011

I have a JQuery template, and I want to call a webservice and populate the fields in it. The issues I am having are, I'm not sure how to pass parameters in my $.ajax call (ideally, I want to pass a dictionary so I can pass as many or few parameters as I want). I tried data: { Key : Value } but get a 500 server error saying something about not a valid JSON primative.

Once the webservice is called, how can I get my data back in a JSON string that is compatible with a JQuery template? My webservices usually get a List and my jquery template works with a JSON object.

The problem is basically the format of data between client and server. My webservice call works fine, it's simply a problem of JSON and data. Edit: I have succeeded in calling the webservice with a dictionary, I am now trying to figure out how to get the data back. I'm getting a circular reference error.

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

AJAX :: JQuery Not Calling Web Method?

Apr 25, 2014

in default.aspx i am calling web method. bt every time its going to error method.

code is...

function login(btn) {
alert('a');
var email = document.getElementById("txtUserName").value;
var password = document.getElementById("txtPass").value;

[Code].....

View 1 Replies

Calling .NET Web Service Function Via GET Method With JQuery

Apr 26, 2010

I'm trying to call web service function via GET method using jQuery, but having a problem. This is a web service code:

[WebService(Namespace = "http://something.com/samples")]
[ScriptService]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [Code]....

And I get an error because of this (error handler is called).

View 7 Replies

Calling Linq To SQL Method In Web Service With JQuery?

Jan 24, 2010

I have a test web service called: MySimpleService.svc with a method called:GetUserNamesByInitials. below is the Linq to SQL code:

[OperationContract]
public static string GetUserNamesByInitials(string initials)
{
string result = ""; [code]...

what I do is to type the user id in one textbox (TextBox3) and when I press the Tab key the result is shown in another textbox(TextBox4).
The jQuery call works well with other methods that do not call the database, for example using this other web service method it works:

[OperationContract] public string ParameterizedConnectionTest(string word)
{
return string.Format("You entered the word: {0}", word);
}

However with the Linq method it just does not work.

View 1 Replies

Calling Jquery Ajax Method From WebUserControl?

Mar 20, 2011

I am using asp.net3.5 C# with Jquery

I have created a webUserControl timer.ascx, I have a page showTime.aspx I have added timer.ascx into ShowTime.aspx on drodown change I want to display the current time.

but I am getting this error

This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden.

[Code]....

View 1 Replies

JQuery :: Function Is Not Calling When Ajax Method Succeed?

Nov 20, 2010

I am doing a small application in asp.net using JQuery

View 2 Replies

JQuery :: Calling Code Behind Method From Javascript Function?

Dec 27, 2010

I have a java script function which presents a countdown timer.when the timer reaches zero, I want to somehow activate a function on the server side in the code-behind.I understand it is impossible to directly call a server-side function, but is there a simple way to still fire it?I want to fire the (event-handler) code behind function: protected void ButtonFinish_Click(object sender, EventArgs e).

var _countDowncontainer = 0;
var _currentSeconds = 0;
function ActivateCountDown(strContainerID, initialValue) { _countDowncontainer = document.getElementById(strContainerID);
[code]...

View 16 Replies

Web Forms :: Control Is Not Going To Visible After Calling The Method In JQUERY?

Aug 10, 2010

I called the server side Method using AJax and inside Method iam going to Add the Media Player to Place Holder i debug the code every thing is ok but Place Holder is not Displaying any thing.

Here is my code of JQUERY

[Code]....

and Here is my server side Method

[Code]....

and in aspx code i just put the DataList for binding the Thumbnail Images and Place Holder control for displying the Media Player .

But Place holder is not going to visible after the calling sercer side Method to JQUERY. Is there any thing iam doing wrong.

View 5 Replies

C# - How To Return False In Javascript Function From JQuery Calling [web Method]

Mar 3, 2011

So in default.aspx I have the code

<script type="text/javascript">
function validateForm()
{ [Code]....

When I call test() from javascript i want it to return false but cant seem to geta value from test.

View 4 Replies

Jquery - Unknown Web Method Exception When Calling Shared WebMethod

Jul 1, 2010

I'm trying to implement a view tracking web service on my website. I'm using JavaScript because I want to exclude any search bots from my tracked views. The problem is I'm getting a "Unknown web method" error when I try to use jQuery to post to the web service I've created.

$(document).ready(function() {

$.ajax({
type: "POST", [code]...

The error is an ASP .NET error: Unknown web method TrackItemView. Parameter name: methodName.I've done this hundreds of times (seemingly), but I just can't see what I'm missing. I'm sure it's something small...

View 1 Replies

Calling Jquery Function From Ascx Not Working?

Jun 11, 2010

I have an ascx which contains a submit button for a search criteria and I am trying to call a validation function in a js file I've used throughout the site (this is the first time I'm using it in an ascx).

Now I've just tried this:

<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/jsAdmin_Generic_SystemValidation.js"></script>
<script type="text/javascript">
$(document).ready(function () {

[Code]....

Now at first I was getting "Validate() is not a function" in firebug. Since I did that alert testing, I am getting the first alert, then nothing with no errors.

View 1 Replies

Jquery Dialog Calls A Server Side Method With Button Parameters?

May 27, 2010

I have a gridview control with delete asp:ImageButton for each row of the grid. What I would like is for a jquery dialog to pop up when a user clicks the delete button to ask if they are sure they want to delete it.
So far I have the dialog coming up just fine, Ive got buttons on that dialog and I can make the buttons call server side methods but its getting the dialog to know the ID of the row that the user has selected and then passing that to the server side code. The button in the page row is currently just an 'a' tag with the id 'dialog_link'. The jquery on the page looks like this:

$("button").button();
$("#DeleteButton").click(function () {
$.ajax({

[code]...

The dialog itself is just a set of 'div' tags. Ive thought of lots of different ways of doing this (parameter passing, session variable etc...) but cant figure out how to get any of them working.Any ideas are most welcome

View 1 Replies

MVC :: Action Method Returning An ActionResult Used In A Action Method?

Aug 27, 2010

I have the Index action method calling a method that itself is an action method.

Example :

[Code]....

What to do in this case ?

View 10 Replies

How To Pass Parameters To An Action Using Html.Action() In MVC?

Jun 30, 2010

I've been using Html.Action("ActionName", "ControllerName") to invoke child actions across controllers without needing to have the view in ViewsShared. This has been working great for displaying things like session or cookie information.

Instead of just accessing cookies, I would like to pass additional parameters to Html.Action("ActionName", "ControllerName") so the action can execute different code based on the the data passed to the original view.

Should I be using a different method to pass parameters to a child action in a different controller?

View 1 Replies

JQuery Method Not Working Second Time?

Mar 24, 2011

I have a JQuery Method. When I click on button "btnSelectDisclosure", a popup appears but only once. Not for next time.

[code]...

View 1 Replies

MVC :: Jquery Post Method Is Not Working In Windows Server 2003

Jul 8, 2010

i working in asp.net mvc project and deployed in the windows 2003 with iis 6.server.But it post method in jquery is not working after hosting. it given all path of the script is correct with Url.Content. The same Project hosted working in xp with iis5.1 it working fine.Give me any solution to run post of the jquery in the hosting server windows 2003.

View 2 Replies

AJAX :: Calling Webservices From Javascript: OnError Method, How To Identify The Method

Aug 26, 2010

I have an application that has JS calling ASMX files to do asyncronous requests, using ASP.NET AJAX.

The problem is that I use always the same "onError" function, and now I don't know how to identify the method that rised the error, and it is giving me a lot of problems to debug errors. The parameter "data" of the onError method does not give enough information, for
example:

en System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
en System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
en System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
en System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)
en System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary`2 rawParams)
en System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)
en System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)
en System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)

Is there any way to know the webmethod that raised the error?

View 1 Replies

MVC :: MVC3 RC2 Bug Binding From Request Parameters To Method Parameters?

Dec 10, 2010

Since ASP.NET MVC3 RC2 I encounter a bug when posting values to a controller method of which one of the parameter is a nullable int. Steps to reproduce:

I've created a test method

[code]....

In MVC3 RC1 this was working without any problems with the nullable int

Update:
I don't seem to have the problem with a newly created MVC3 website. What could I have in my project that influence model binding to nullable int's? And why would there be a difference between RC1 and RC2?

View 10 Replies







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