My 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:
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..
I have IEnumerable object with value1 and value2. value2 is an array and value1 is string. I want to databind this object to Listview like that. So both value1 and value2[0] (always first item in array) could be accessed via <%# Eval("value1") %> and <%# Eval("value2") %> .
How can I enable automatic sorting of my BLL which returns a list, CustomerList:List in a GridView? Customer is my own strongly typed class and CustomerList is a List of customers.I know one approach is to set the AllowSorting property to true in the GridView and handle the OnSorting event and calling a sorting method defined in my CustomerList class.
However I would like a solution which is automatic in the sense that I do not have to handle the OnSorting Event, it should be like how GridView handles automatic sorting for DataView, DataTable, and DataSet.Is there an Interface I need to implement on my CustomerList or Customer class that will enable that functionality?
I have a dataset that has two datatables. In the first datatable I have EmpNo,EmpName and EmpAddress. In the second datatable I have Empno,EmpJoindate, EmpSalary. I want a result where I should show EmpName as the label and his/her details in the gridview. I populate a datalist with the first table, and have EmpNo as the datakeys. Then I populate the gridview inside the datatable which has EmpNo,EmpJoinDate and EmpAddress. My code is
What is the most straight forward way to use AuthorizeAttribute and JsonResult together so that when the user is not authorized the application returns a Json error rather than a log in page?The two things I am currently considering are extending AuthorizeAttribute or just making a new attribute that implements IAuthorizationFilter.
How do I accept an 'object' as a Datasource (IEnumerable or IList) and loop through the keys/values? I want to be able to pass anything that implements either IEnumerable or IList.
This same functionality exists on all of the .Net DataBound controls and I'm trying to figure out how it's done.
I have some stored JSON strings stored in the DB which I want to return to the client as JsonResult . I know that Json(object) turns an object into JsonResult but what if I already have the result in a string ? can I cast it to JsonResult
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method that returns a JsonResult. Everything works great except when the response gets back to the browser it is treated as a file download instead of being passed into the success handler. Here's my code:
Javascript:
[Code]....
If I open the downloaded file the json is exactly what I'm looking for and the mime type is shown as application/json. What am I missing to make the jquery.ajax call receive the json returned?
I would like to wrap a RenderPartial in a JsonResult so that my jQuery can handle placement/positioning of the html data based on additional Json parameters.
e.g. {html: <string returned from RenderPartial>, typeofdata: 1}
After Googling, it seems that the only way to do this is a workaround that hijacks HttpContext in order to spit the PartialViewResult into a string. However, this seems like it would break testability.
Is JsonResult not intended to be used with RenderPartial?
Alternatively, I could set typeofdata as a parameter of the model, and have the PartialView render it as a hidden field, then have jQuery look for it. What is a better way to generate the data that I need?
I'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?
I am creating an MVC project with a table using the JQGrid plugin. I would like to use a DropDownList to allow the user to specify a value, that will be used in an SQL query to retrieve specific data from the table. I.e. user can select a country from the list, and the table will display items only from that country. I cannot figure out how to retrieve the selected item from the DropDownList, within my data bind function for my table, within my controller class.
DropDownList in the View
<%= Html.DropDownList("Countries")%>
Setting up the DropdownList in my controller
//dt is a DataTable which holds the values for my list List<SelectListItem> countries = new List<SelectListItem>(); for (int i = 0; i < dt.Rows.Count; i++) [code].... The problem seems to be that within a JsonResult function I don't have access to the ViewData or my ViewModel, which always seem to be null when I try and access them. I am very new to MVC and web development,
I am using LINQ for data connectivity and have made class which return me the result set into presentation here is the syntax:-
public List<ClsDermaInvestigation> MthdisplayInvestigation() { List<ClsDermaInvestigation> lstinvst = new List<ClsDermaInvestigation>(); ISingleResult<USP_Patient_Dermatology_InvestigationResult> investresult = objderma.USP_Patient_Dermatology_Investigation(PatientID, RepDate, Hb, TLC, F); foreach(USP_Patient_Dermatology_InvestigationResult rel in investresult) { ClsDermaInvestigation objinvest = new ClsDermaInvestigation(); objinvest.Albumin = Convert.ToDouble(rel.Albumin); objinvest.ALP = rel.ALP; objinvest.ANA = rel.ANA; objinvest.Date = rel.date; lstinvest.add(objinvest)}return lstinvest} This list is returning me the result.It works fine but in 1 case am using the same list to bind my Date dropdownlist. //aspx.cs code List<Dermatology.ClsDermaInvestigation> objlstinvest = objinvest.MthdisplayInvestigation(); //Array s = objlstinvest.to drpDate.DataSource = s; drpDate.DataTextField = "Repdate"; drpDate.DataValueField = "Repdate"; drpDate.DataBind();
But it throws an error that list does not conatin a property with "Repdate";. How can i bind this list with dropdownlist?? Can i convert it into some type so that i would be able to bind it??