Jquery - Set Session In PageMethod?
Apr 5, 2011
I need to set a couple of Session vars by calling a PageMethod using jQuery.
The client side js looks like this:
function setSession(Amount, Item_nr) {
//alert(Amount + " " + Item_nr);
var args = {
amount: Amount, item_nr: Item_nr
}
//alert(JSON.stringify(passingArguments));
$.ajax({
type: "POST",
url: "buycredit.aspx/SetSession",
data: JSON.stringify(args),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
alert('Success.');
},
error: function () {
alert("Fail");
}
});
}
and the server side like this:
[System.Web.Services.WebMethod(EnableSession = true)]
public static void SetSession(int amount, int item_nr)
{
HttpContext.Current.Session["amount"] = amount;
HttpContext.Current.Session["item_nr"] = item_nr;
}
only, it seems that the Session vars are not set. When I try to Response.Write out the Session vars, I get nothing. I get no errors, and I can alert out the values passed from the onclick event, to the js function, so they are there.
View 2 Replies
Similar Messages:
Feb 24, 2011
The Situation: When there multiple PageMethod calls in a single page, each of the method call holds a lock on the Session object thus blocking. The PageMethod calls can be made asynchronous only with @Page directive is turned to False|ReadOnly
Findings: When the Page directive is default (read/write) but the session is not used anywhere on the page, the calls are not blocked. Any read or write in to the session at the page level blocks the pagemethod calls.
The Problem: Making EnableSessionState=ReadOnly at the @Page directive is very restrictive and don't want to take that route. Can the pagemethod calls not block? and still access the session? (may be not write but just read)
View 2 Replies
Feb 10, 2011
I am trying to call a PageMethod using jQuery like this:
[WebMethod]
public stataic string WebMethod(PostData data)
{
//DO WORK
return "a";
}
PostData class is as follows:
[Code]....
View 2 Replies
Mar 21, 2011
I have a user control having a pagemethod. I want to call this pagemethod from my page using jquery's ajax() method?
View 5 Replies
Mar 17, 2011
I have a page method which take in a complex parameter how can i call this page method using jquery.
This is my page method
[Code]....
and these are my types
[Code]....
View 2 Replies
Feb 18, 2011
I have a simple aspx file with 2 text boxes and an ajax autocomplete extender attached to textbox2
[code]....
This not working.. How can i make it work?
View 1 Replies
Mar 18, 2010
I have a long running process that i kick off with a pagemethod that normally takes about an hour to complete, when it is finished it returns the result of the method.I then poll with another pagemethod to update the status of the first process.the process is taking 4.5 hours this week which is acceptable and understandable, but the feedback sometimes gives up after a couple of hours and sometimes the main method never returns any feedback to the client.
Regardless of the lack of status updates and final feedback the server still completes the long task.As far as i'm aware we have made no changes to any timeout values.is there a timeout setting that we are hitting that is above 1 hour for ajax methods?
View 2 Replies
Oct 21, 2010
I have a pagemethod that saves data to my database. Initially I worked on editing an existing record. So I'd load a page by adding the FileNumber to the url:
Code:
[URL]
for example. Then on the click of my save button I send all the textbox ojects etc to a javascript function which then gets the values to save, and passes them to my pagemethod. I did this so I won't have to have refresh the page each time a user updates the file. ajxaified it in other word. Now whan creating a new record, I pass -1 as the fileNumber in my querystring. I do this so in my code, I will know it is a new record and I will write the required logic. However once the new file is created, I get the its primary key value by using SCOPE_IDENTITY(). then unless I refresh the page from my javascript function the url will remain
Code:
[URL]
View 16 Replies
Jan 12, 2010
I am using an AJAX.Net to call an ASP.Net PageMethod, which returns JSON serialized JSON data
{"d":"[{"Fromaddress":"testfrom1@test.com","Toaddress":"testto1@test.com"},{"Fromaddress":"testfrom2@test.com","Toaddress":"testto2@test.com"}]"}
The Response Header states the content type as
"Content-Type application/json; charset=utf-8"
However, the data is just available as a string, and does not seem to be available as JSON data from javascript. What do I need to do to work with the returned data as JSON from javascript?
View 1 Replies
May 30, 2010
I have a PageMethod that works perfectly well when it either (a) running in the VS dev server, or (b) deployed but marked with UseHttpGet=false.
What doesn't work, and is driving me mad, is having UseHttpGet=true and then deploying it to a test server (Vista & IIS7). It fails to call through the proxy with error code 404 coming back. But it works find if I set UseHttpGet=false.
I have gone through all of the basic stuff I can think to check, and as noted it works perfectly well on the dev box. So there must be something particular about full-blown IIS7 and its config that I am missing..
anything to check in the IIS manager that would cause this to fail? I've tried with forms authentication enabled and disabled, as a few posts mentioned issues with that.
View 1 Replies
Mar 3, 2011
I have a page that requires user login via Forms Authentication. Is it possible to use Page Methods in this page? My current attempt is resulting in the following error:Message: Sys.Net.WebServiceFailedException: The server method 'GetPlanContent' failed with the following error: System.InvalidOperationException-- Authentication failed.
View 2 Replies
May 13, 2010
PageMethod which supposed to be called/executed when "onChange' of dropdownlist is triggered is Not being executed. I have 3 dropdownlist being created at runtime/dynamically inside a compositecontrol class and loaded (.dll) in a page at runtime. I have added a scriptmanager in the master page and set EnablePageMethods to true, tried placing the webmethod function outside of the compositecontrol and in the page, still webmethod is not being called... Anyone has idea or solution to this problem of mine? Or another approach to retain the selected value of the dropdownlist inside this compositecontrol (.dll) that is being loaded in a page at runtime?
[Code]....
View 2 Replies
Jun 28, 2010
I put my ScriptManger on the top level Masterpage with EnablePageMethods set to "true".2. I put a AutoCompleteExtender (AjaxToolkit) on a second level Masterpage which derives from the top level MasterPage. The AutoCompleteExtender is used for search with a TextBox. The PageMethod is defined in the Code Behind of this second level Masterpage.3. I have several Contentpages that derive from the second level Masterpage.Problem: The AutoCompleteExtender does not work and that's probably because the PageMethod is defined in the second level MasterPage in the CodeBehind and not in the Contentpage. Ok, so I'm pretty sure what causes the error,- I do not want to use a WebService, because I don't want the search to become public. And as far as I know you can't define a WebService that is only visible to the Website itself - it's always public.- It would be stupid to put the search on every Contentpage just for the PageMethods sake.
View 1 Replies
Jun 16, 2015
My website is running fine on my local system but when i upload it on IIS6 of my local computer [Ajax.AjaxMethod] is not working. How i will solve it.
View 1 Replies
Nov 9, 2010
I want to render a user control in pagemethod and return the html back to client. But its getting annoying, I tried like many ways but nothing found working. The problem is that, the usercontrol require both HtmlHead and ScriptManager.
I tried this but it doesn't work(raise error : ScriptManger require in page) because ScriptManager must be inside HtmlForm but Page.Form always null.
[Code]....
View 8 Replies
Jun 29, 2010
I have written an application that relies upon PageMethods. It was working fine in .NET 3.5 where I would rely upon exceptions to signify something failing during the call. I would then alert the user to what ever it was that happened. All was working great. I transitioned to .NET 4.0 as I am intrigued by the Parallel Computing improvements. Now any exception that I throw in the PageMethod in the code behind is met with an Unhandled Exception. Nothing has changed other than the target framework.
View 5 Replies
May 6, 2010
We have used the ajax toolkit auto complete extender in an intranet app which uses Windows authentication. The auto complete uses a static page method in the page code behind to get the results. Even though the page containing the auto complete is authenticated by the server and the asp.net session id set in the cookie, the initial requests from the auto complete result in 401.1 and after few attempts result in a 200. This irritates the users of the app. Also later on there are 401.1 happening intermittently among the various 200 there by affecting the responses.
I have verified these responses by using Microsoft Network Monitor,Fiddler and Firebug. Also these entries are present in IIS logs. I tried to implement the same with a script service but that too gives same issues. Our site has lots of ajax features and controls and everything is working fine, only this issue is there.
<asp:ScriptManager ID="smHome" runat="server" EnablePageMethods="true" AsyncPostBackTimeout="600"> </asp:ScriptManager>
<CustomControls:StyledAutoCompleteExtender runat="server" ID="acAssociateSmartSearch"
TargetControlID="txtSmartSrch" ServiceMethod="GetAssociateSmartSearchList" MinimumPrefixLength="2"
CompletionListCssClass="sscompletionListElement" CompletionListItemCssClass="sslistItem"
CompletionListHighlightedItemCssClass="sshighlightedListItem" CompletionSetCount="10"
CompletionInterval="500" EnableCaching="true">
View 1 Replies
Nov 30, 2010
My Pagemethod implementation is not working in Chrome browser. I have ASP.NET 3.5 web application developed in VS 2008.
The code below not working in chrome or Safari:
function FetchDataOnTabChange(ucName)
{
PageMethods.FetchData(ucName, OnSuccessFetchDataOnTabChange, OnErrorFetchDataOnTabChange);
}
function OnErrorFetchDataOnTabChange(error)
{
//Do something
}
function OnSuccessFetchDataOnTabChange(result)
{
//Do something
}
View 2 Replies
Nov 8, 2010
Im throwing some helpful exception in PageMethod and showing them on client side, It was working fine on local machine but when I tested on production site, its just showing "There was an error processing the request.".
View 3 Replies
Nov 16, 2010
I have a function :
$("#LBAvailable").click(function () {
var str = $("#UserName").val();[code]....
But i cannot get the session variable "lang" -> var sess = '<%=Session["lang"]%>'; How can i pass this variable? What is the syntax?
View 2 Replies
Jan 13, 2010
I have an ASP.NET PageMethod with the following signature:
<WebMethod()> _ Public Shared Function SaveCodes(ByVal codes As List(Of Code)) As String
I am trying to pass a JSON object to the PageMethod from the client side, but I get an error that the type String cannot be converted to type of List<Code>.
Here is the json that I'm building on the client and sending to the method:
[code]....
I have been able to pass in simple data types and a single instance of the Code class, but I can't seem to find the magin to pass a List to the server method. Can anyone show me what I'm doing wrong?
View 1 Replies
Jun 14, 2010
I have a long running PageMethod defined in the cs that is being called from javascript and after 4 minutes I am getting the below error and 504 status code for my aspx page and onFail callback is raised.
<HTML><HEAD>
<TITLE>Gateway Timeout - In read </TITLE>
</HEAD><BODY> [code].....
View 2 Replies
Jul 1, 2010
need to send a byte array from javascript into a c# page method. The int and string variables work fine, but when I step through the c# code, the "object" which was the byte array is null, even though I checked to see if it had a value in JS.
var byteArrayObj = GetBinaryDataFromFile(filePath);
var tranAttachmentName = filePath.replace(/^.*\/, '');
PageMethods.AddFileToTran(tranId, tranAttachmentName, byteArrayObj, RefreshPage, onTimeout, onError);
[code]...
View 1 Replies
Apr 24, 2010
I am looking write a javascript method as such called when a dropdownlist changes value
function GetStuff(sender, destID){
var dest = document.getElementById(destID);
this.PageMethods.GetStuffs(sender, dest, null, null);
[code]....
View 1 Replies
Jan 24, 2016
Is it mandatory to pass the Success and Failure method names as parameters while calling server side methods using PageMethods in client script.
I referred to article [URL] ....
View 1 Replies