AJAX :: ASPX WebMethod Not Running The WebService Webmethod Returning The Page?
May 19, 2010
I have a service that works great on my development box. It uses JQuery to hit my web service, and then the JSON results are sent back.
The web service is located on our basePage.cs. We didn't want to put out an external WebService for this. Our on beta box something different is happening.
The web page seems to be trying to call the web method correctly - the JSON data is being sent... but the server doesn't seem to know it's a webmethod. here's my service function (it's in our basepage.cs which inherits from Page).
I have a simple web method written in the code-behind (not a separate asmx) of a test aspx page.
All it does is return a DataTable(or DataSet) both are failing, gives a blank 500 error saying "There was an error processing the request"
If I switch the return variable type to String, it works fine
I think my issue has to do with the version of the System.Web.Extensions, is that the assembly that actually contains the JSON communication implementation?
I've read all kinds of tutorials about how it should be possible to return the DataTable to javascript and then read the properties with javascript syntax.
For some reason it isn't working for me.
My web extensions is imported through my web.config with the following version
I set the Session["PhotoId"] in a normal aspx. But I can't retrieve value in the webmethod of the aspx page.
[WebMethod(EnableSession=true)] public static string Submit(string data1, ...) { string test = HttpContext.Current.Session["PhotoId"]; // test is null }
I have jquery using ajax/json to grab an elements ID and then hits:
[System.Web.Services.WebMethod] public static string EditPage(string nodeID) { DataTable dt = new DataTable(); using (SqlConnection con = new SqlConnection(Global.conString)) using (SqlCommand cmd = new SqlCommand("contentPageGetDetail", con)) { cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = Global.SafeSqlLiteral(nodeID, 1); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } } if (dt.Count > 0) { string pageTitle = dt.Rows[0]["Title"].toString(); string contentID = dt.Rows[0]["ContentID"].toString(); return pageTitle, contentID, nodeID; } else { return "Failed"; } }
When it's time to return I want to grab all content returned from the stored procedure back to the jquery method in the success section and set a hiddenfield, dropdown value, and a title in a textfield. In the jQuery I tried using "pageTitle" but it came up undefined. What do I need to do jQuery side to grab whats being returned and populate fields in my Web Form before showing the form?
Service: [WebMethod] public void GetCommission(List <BOLibrary.Flight.DTContract>Loc) { }
At the client side i am Passing the parameter Client
List<BOLibrary.Flight.DTContract> BoList = new List<BOLibrary.Flight.DTContract>(); BOLibrary.Flight.DTContract dtConboj = new BOLibrary.Flight.DTContract(); dtConboj.ValidatingCarrier = "AA"; BoList.Add(dtConboj); BOLibrary.Flight.DTContract[] pass = BoList.ToArray(); service.GetCommission(pass);
But the Problem is that the service.GetCommission(pass) accpect the argument of servicenameSpace.DTContract but in client in client i have BOLibrary.Flight.DTContract so how can i pass the parameter to the to the Service.
I have a classical asp.net web service (asmx) and a web method in it. I need to throw a custom exception for some case in my web method, and I need to catch that specific custom exception where I call the web service method.
[Code]....
However, I cannot do that because when I add the web service reference on the client, I have service class, input and output classes, but I do not have custom exception class.
Also another problem is that, I have also problems with serializing Exception class (because of Exception.Data property implements IDictionary interface)
Is there a way to do this in my way, or am I in a completely wrong way, or is there something I miss about fundamentals of web services?
and I am calling the webmethod by javascript like this [Code]....
The result is, I get the error function running and I get "undefined error" alert.Am I calling the procedure correctly? I put a breakpoint on the webmethod and it.
I've a problem: I've a GridView, with a folder structure, and an asp.net checkbox for each row in the gridview.Now, when the user clicks the delete button, it should delete all the folder entities where the user checked the checkbox.The problem is, there may not be a postback...So I used to use findcontrol in an ordinary asp.net button codebehind, but in a webmethod, it's impossible to access the page object, because WebMethods need to be static...Now I tried ctype(httprequest.current.request.handler,page) but that doesn't seem to work...
How can I get the page object to use findcontrol ?
I have the following web method , no success on return a correct Json format.
[Code]....
GetAll() return list of type "Company" POCO classes.
The web method complaint type "Company" could not cast to object. However I could not just return the Company type because client side Json only accept its 2 properties -"CompanyName", "ID" and I want to keep it that way.
Of cause, I had tried create a CompanyDTO which only have those two properties, but same error - "Unable to cast object of type..."
How should I modify in my web method to make it able to return a list of partial "Company" type in Json format?
to fetch data to popup control dynamically I used webservice [WebMethod]public string getIssueDetails(string contextKey){ } But before that I set ModalPopupExtender1.DynamicContextKey = "1_1_60"; in code behind.But problem is in webmethod "contextKey" is getting passed as null.
I am using a webform and trying to use a $.ajax call a webmethod on my code behind to format and return some data. It sounded easy but I need the help of an expert. Here is what I have and perhaps someone could steer me in the right direction to solving this problem. for the time being all I want the [webmethod] to return is some dummy data so the jqgrid displays, after I get it displaying correctly I will work on the data column format. So for this sample to work correctly user would open web from and click on button "Load Grid" when this is clicked it calls the the [webmethod] on the server, the sever then gets the data and passes it back to the jquery .ajax call and then it gets loaded into the jqGrid.
I am trying to create a function that when a button is clicked it will pass all my records to my json page which will save my data. This is what i have so far
var t = this; t.RecordsSave = function ($http) { for (var i = 0; i <t.records.length; i++) { var record=t.recordss[i]; var data = params( { record: record.Number[i],
[Code] ....
I get the following error "params is not defined"
and "Cannot read property '0' of undefined"
How should i go about this. not familiar with angular js