MVC :: Can JsonResult Method Return Data Table
Jan 16, 2011I am wondering if jsonResult method can be used to return Data Table? If so, is it a json array or a json string?
View 6 RepliesI am wondering if jsonResult method can be used to return Data Table? If so, is it a json array or a json string?
View 6 RepliesI've got an ActionMethod that returns a JsonResult object and this isn't returning data to the calling jquery function. I have used wget to send and receive raw data to it, and I've discovered that when the object dataset is empty, it returns a value fine and the wget return is
HTTP request sent, awaiting response... 200 OK
Length: 78 [application/json]
Saving to: `filename'
but when there is data in the object dataset I get an internal server error:-
HTTP request sent, awaiting response... 500 Internal Server Error
2010-03-05 13:21:16 ERROR 500: Internal Server Error.
This is a dataset of objects being returned - are there any common "gotchas" when doing this?
how can i return 401 error from a method return ActionResult?
View 1 RepliesI am coding a classic .asmx web service. The method get data (as a string) from a server, then assign data to an object, then return that object. But I want to cache that object to a XML file for other request. It's because the data from server is not frequently change. Thus, after some minutes, I have to refresh the XML file. When I refresh XML file, I could write object to XML first, then return that object, but that approach maybe slowly.
How can I return the object for client first, then write this to XML file?
What i need to do: When i click button on my .aspx page WCF service should be called, which should return data from ADO.NET entity data model. Entity data model and webservice is already added. I just have to write a method which will return data from data entity.
View 2 RepliesIn my asp.net website I need to return data obtained from DB by adding html tags to it from a server side method,just like a webmethod returns jsonified data. I am having trouble understanding if a webmethod can serve the purpose(i.e., htmlifying the data).If not how do I acheive it?
View 1 Repliesi am new in json script.am trying to convert the database table value into json using asp.net with c#.here, am also send the response to asp.net client side.but am not receiving any response from server side.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
[code]...
function createSuccess(context) {
$get("result").innerHTML = context.get_data();
}
<% using (Ajax.BeginForm(new AjaxOptions {OnSuccess="createSuccess"}))
{%>
What does context holds in the createsuccess method? data return by controller? How do we return json data in the createsucess if so
I am new to Sql server 2005. I have a table in which contains many data. I need to take particular data. For example, I want to take value of 110652.795813712 from FTEBASEPAY column. So i have wrote the sql statment like in below. SELECT * From tblEmployees where FTEBASEPAY='53842.7782655718' But i am not able to get the particular value. Manually i have seen the tblEmployees table, in which contains the particular data ('53842.7782655718'). When i execute the above select statement, there is no result for it. What i have to for overcome this issue?I have to give one more information, the FTEBASEPAY dataType is float in tblEmployees table.
View 4 RepliesMy controller has a member that returns a JsonResult object, it is coded as per below. The problem is that Json(users) only returns the data from IEnumerable (MembershipUserEx objects) and I also want the data from the public Properties of MembershipUserExCollection as well. Is there a way to do this? I guess I am looking for the Json object to look something like this pseudo object:
results = {
pageIndex:0,
pageSize:50,
[code]...
How Can we Show Data in a View By passing a jsonResult?
View 1 Replies1)table student
studentno varchar(50)
hobby1 varchar(40);
hobby2 varchar(40);
hobby3 varchar(40);
2)if record in data database such that
hobby1 hobby2 hobby3 in this maximum is one must be chose
like
here studentno hobby1 hobby2 hobby3
1 cricket null null
2 null hockey null
3 null null tennis
if i want to write function in mysql if i pass the studentno
i want to get the hobby of respective student
like select functionname(1)
your hobby is cricket
like select functionname(2)
your hobby is hockey
ike select functionname(3)
your hobby is tennis
i want to use MVC 2 actions to pass JSON data to a 3rd party application via a URL.The URL will be in the form of http://www.abc.com/controller/action..I am using JSonResultHow can i test the output of this URL to ensure the JSON is properly formed..
View 2 RepliesI am adding table rows dynamically, after I return from a post back, these rows disappear.
Is there a way to preserve these rows and add them back on page load?
i use JSon to return allot of results when building a website, but find myself writing a a lot of code like this:
[Code]....
and then simply call this function with whatever IEnumerable results i have my question is would i be on the right lines here, what would be the best possible way to do this as it makes no sense to be writing in MVC and OOP but to keep rewriting code to just FROM ?
I have a class file called ShoppingCartClass.cs. Inside ShoppingCartClass I have a method called CanadaPostShipping.
CanadaPostShipping get passed a lot of variables and then builds an xml, sends it to CanadaPost url and gets back an xml file with the shipping rates.
I would like to pass the xml back to my webpage so in my web page I can check that it has status ok and then extract the information I need.
My testing calling routine looks like this:
[Code]....
The start of my CanadaPostShipping routine looks like this
[Code]....
This is my current ending spot in CanadaPostShipping....where I am getting back the correct xml from CanadaPost
[Code]....
As you can see I am saving it to my thumbdrive.....
What changes would I have to make to my calling routine and the method in the class to return xml "mydoc"?
I'm really new to ASP.Net and for a school project we have to create a login form. Now I have managed to create a login with LINQ doing the following:
[Code]....
And in my html page:
protected void Test_Click(object sender, EventArgs e)
{
if (Class1.Controle(Convert.ToInt32(txt1.Text), txt2.Text))
[Code]....
I was thinking something amongst those lines, but I can't call p.GebruikerWachtwoord. So I'm guessing this is completely wrong.I hope somebody can help me figure this out, and I apologise for the poor explanation, English isn't my native language.
I am fairly new to MVC and just trying to achieve something which I think shouldn't be too complicated to achieve. Just want to know what the best approach for that is. I have an Event-RSVP application (NerdDinner kind) where you go to view details of the event and then click on an AJAX link that will RSVP you for the event.
<%
if (Model.HasRSVP(Context.User.Identity.Name))
{
%>
<p>
You are registered for this event!
<%:
Ajax.ActionLink("Click here if you can't make it!", "CancelRegistration", "RSVP", new { id = Model.RSVPs.FirstOrDefault(r => r.AttendeeName.ToLower() == User.Identity.Name.ToLower()).RSVPID }, new AjaxOptions { UpdateTargetId = "QuickRegister"})
%>
</p>
<%
}
else
{
%>
<p>................
VWD 2008 Express. Visual Basic.
I am using the Directory.GetFiles method as follows:
[Code]....
As expected, it returns files with the ".pdf" extension. I would like to be able to specify more than one extension (like "*.doc*" and "*.txt*", etc.). How can I use GetFiles to return files with more than one desired extension, without returning all files?
I have two methods that do the similar thing. There are small differences here and there, which I can control by passing arguments to them when I call them, so I can effectively merge them. However one returns a string, and the other one an ArrayList. On the top of my head, I could merge them and return an Object, and then get the information I need. Is there a way though to return multiple types in the method's signature? What's the proper way to implement this?
View 5 RepliesI am trying to return some data as json from an action method.
I have an employee object that looks like this:
public class Employee
{
public int EmployeeID {get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
//Other irrelevant properties
}
Then I have a view model as follows
public Class EmployeeViewModel
{
public Employee Supervisor{get; set;}
public List<EmployeeViewModel> Employees
}
I need to return a json object that looks exactly like this:
{id: 1, name: John, children: [
{id: 1, name: Joe, children: []},
{id: 1, name: Rob, children: []}
]}
For now I only need to go to the second level as above, returning and supervisor and their staff members beneath them.
How would I go about returning this in my action method(I have the viewModel object hydrated already I just need to return it as json). My problem so far has been that the children property does not get populated.
I have a problem trying to retrieve a return value from a javascript function and using it from my code behind. The problem is after I call my UpdatePanel.Update() method and call return, I can't continue as I have ended execution of the page by calling return. Please find an example of my code:
[Code]....
I'm using ASP.MVC 3 with SSRS 2008 R2. I have some reports which I want to render as PDF document. So I my controller, I've got this code
[Code]....
Problem is, that this code returns empty pdf. If I call PrintReport directly from view, then it works. But when I call ReportSwitcher, which calls PrintReport, then it returns empty file.
i call FormsAuthentication.RedirectToLoginPage() to redirect to login page. but there is one problem: this method adds a return url to query string.how should i disable this?
View 3 RepliesI want to use a function in the code file of ASP.NET such that everytime the function is called, its value increases by 1.I thought of a way but it didn't fully work out. I created a class for this and used a static variable in that but the lifetime of static variable in asp.net is till the time the app does not close.
public class Class1
{
public Class1()[code]....