Passing Complex Objects To Javascript Via IScriptControl?

Mar 24, 2010

I'm playing around with a asp.net page that's using the IScriptControl interface to pass data from the code-behind to the custom javascript object running on the browser.I'm passing a number of properties via IScriptControl.GetScriptDescriptors(), and they're all working fine, except for one.That one is a class derived from System.Collections.Generic.Dictionary<>. And even that one has been working for me, so long as the elements in the collection were scalars - ints, doubles, and strings. But when I tried to pass a member of a class, it showed up as a null object in the javascript. The class in question is marked [Serializable]. I changed it to a struct, and got the same behavior.It looks as if the serializer used in IScriptControl does a shallow copy.

View 2 Replies


Similar Messages:

AJAX :: Sending Complex Objects From JavaScript (client) To C# (server)?

Mar 26, 2010

I have this object in my server side:

[Code]....

Now I do this on the client side, to send a typed object to the server:

[Code]....

and actually it works. The problem is that I cannot find the way to stablish this property: "public ThingDetails[] details;"

View 7 Replies

C# - Why It's Not Possible To Debug IscriptControl Javascript Code

Dec 7, 2010

I use visual studio 2008. When I set breakpoints on code they don't break. So only thing I can do is to debug "manually" using firefox with firebug.Is there a way to debug with Visual studio?

View 1 Replies

C# - ModelBinder With Multiple Selection And Complex Objects?

Feb 22, 2010

I'm trying to bind the selections in a multiple selection SELECT, to an IList input in the controller.

<select name="users" multiple="multiple">
<option>John</option>
<option>Mary</option>

[code]...

View 2 Replies

MVC :: Creating Multiple Complex Objects With A Webform?

Mar 3, 2010

I have a form which I use to create an issue. WHen you post the form, the form elements are that of a custom DTO. The DTO is then used on my POST method to create the new entity. That all works fine.

However, I want to add the functionality to add multiple issues at the same time from the same view. In effect, the user would click something like 'Report Additional Problem', and an extra set of form fields would appear (I will like use jquery for this, which I don't have an issue with). However, even with just leaving one set of form fields, the user should still be able to create just one issue. But if I habve my post method take a list or array of my DTO, it doesn't work.

Here is the post method before editing:

[Code]....

What I want to do is for this to take an array or list of NewIssueDto. I would then loop through each one in the list and create a new issue from it.

View 3 Replies

Use ObjectDataSource With Complex Objects And FormView Control?

Dec 30, 2010

I have a complex object. For example a SCHOOL object that contains a collection of PERSON object. How can I use the ObjectDataSource control with a FormView and flatten the complex object? An example display would be to display the school name and comma separate the students on the page. Is this possible?

public string Id
{
get { return m_id; }

[code]...

View 1 Replies

C# - How To Bind A DataTable With Complex Data Objects To A GridView

Jan 31, 2011

My DataTable is programatically generated, and contains objects of type JobInstance in the cells.

[Code]....

When I bind this DataTable to an ASP GridView, it only displays the first column. But if I remove the "typeof(Job)" when creating the column (the line with // !!!), the GridView displays all the columns by showing the result of JobInstance.ToString() in the cells. However, I have no access to the underlying JobInstance object, only the string values that are being displayed.

I need access to the JobInstance object when displaying the GridView (for example in the OnRowDataBound), because I want to access the fields inside JobInstance for each cell to determine formatting options, and add other links in each cell.

View 1 Replies

Use FormView In Order To Insert Complex Entity Framework Objects?

Jun 11, 2010

I'm trying to use formview in order to do insert of a new entity object (called Customer) Customer has a reference to another entity called Address. How can I fill both of them in the same formview?

View 1 Replies

DataSource Controls :: LINQ Mapping To Complex Business Objects?

Feb 5, 2010

I have two business objects mapped via LINQ to tables. One of the objects contains an instance of the other object and share a key as an identifier.I want to retrieve Class A and within class A all of Class B's values as well. What I am doing is this:

[Code]....

[Code]....

This seems a little clunky, as in slow. Is there a better way to get the Class B (User) information without making a query every time?

View 4 Replies

Entity Framework - Collection Of Complex Child Objects In MVC 3 Application?

Feb 20, 2011

I want to be able to update a model and all its collections of child objects in the same view. I have been referred to these examples: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx and http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ .

For example, I have an object Consultant, that has a collection of "WorkExperiences". All this is in an Entity Framework model. In the view, the simple properties of the Consultant object is no problem, but the collection I cannot get a textbox to show up for. I tried following the examples in the links above, but it doesn't work. The problem is, in those examples the model is just a list (not an object with a child list property). And also, the model again is an EF model. And for some reason that doesn't seem to work as in those examples.

[Code]....

This stuff with the EditorTemplate works fine in Phil Haack's sample project, which I downloaded to try, but here, with the EF model or whatever the problem is, I don't get any textbox at all. The table in the view is just there as a test, because in the table I do get the rows for WorkExperiences, whether I add an empty WorkExperience object or fill out its properties doesn't matter, the rows show up for each object. But again, no textbox...

View 2 Replies

C# - Best Way To Edit And Update Complex Viewmodel Objects Using Mvc2 And Entity Framework?

Apr 2, 2010

I have a table in my database with a one to many relationship to another table, which has a relationship to a third table:

[Code].....

This seems to work fine. My question to you good folks: Is there a correct way to do this? I tried following the making a custom model binder per the blog link I posted above but it didn't work (there was an issue with reflection, the code expected certain properties to exist) and I needed to get something going ASAP. PS - I tried to cleanup the code to hide specific information, so beware I may have hosed something up.

View 1 Replies

Passing Complex JSON Data JQuery To Action?

Dec 1, 2010

I have 2 classes that are used to mirror the data from an ajax call. One (Customer) contains a property which is name, and the other is an array of Products.

Public Class Customer
Private _Name as String
Private _Products as Product()
Public Property Name() As String

[Code].....

View 1 Replies

ADO.NET :: Passing A Complex Model To A Create View So It Can Be Populated On The HTTP-Postback?

Oct 25, 2010

I have a somewhat complex model that I need to pass to a MVC 2 Create view so its properties can be filled out. I'm not sure how to actually create this model as it has some relationship data that must also be filled out during the creation process.My main model is a Game. Most of its properties are scalar. It contains a foreign key to Content, for the game reviews, and there's a many-to-many relationship between Games and Platforms - games can be on a variety of platforms (PS3, XBox 360, etc.), and each platform has a library of games.When I pass data to my Edit view, it's as simple as:

[Code]....

I'm unsure what to do in the case of Create as I'm not sure how to link the associated parts - Content and Platforms - to a Game object.

View 1 Replies

Passing Objects To Methods In Mvc 2?

Aug 30, 2010

I have this snippet in my html... Fusion Charts requires I feed it an XML to create a graph

<script type="text/javascript">
var myChart = new FusionCharts("/Content/Fusion_Charts/Charts/Column3D.swf", "myChartId", "470", "350", "0", "0");
myChart.setDataURL("/XML/Graph/?list=<%=Model.list%>");
myChart.render("Graph");
</script>

So in my XMLController I simply have a method like this

public ActionResult Graph(FusionChartsList list)
{
return View(list);
}

So my question is... how can I get the object to actually populate when passing it as url parameter??

View 1 Replies

$.ajax(..) And Passing Custom Objects By Ref?

Dec 10, 2010

How to use $.ajax(..) JSON to invoke asmx webmethods that have 'by ref arguments' for custom classes/objects? Is it possible?

My c# code -
public class MyCustomClass{ public int MyProperty; MyCustomClass(){}}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Method1(ref MyCustomClass MyCustomObj)

[code]...

This all works fine if the webmethod's argument is NOT by ref.With the above mentioned signature of the webmethod, i.e. with a by ref argument, I get a server error (in server response seen using firebub ) -

View 1 Replies

MVC :: Passing A Collection Of Objects To The View?

Apr 16, 2010

I'm trying to pass a list of items from a LINQ query to a View, but I'm having trouble figuring out how to resolve a type issue. Here's the error:

The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[Project.Models.Diagnostic]' but this dictionary requires a model item of type 'Project.Models.Diagnostic'.

The issue seems to originate with this code from my Controller:

[Code]....

I tried changing the IQueryable<Diagnostic> to var and got the same error. Also played around with something like:

[Code]....

But then VS2008 says that diagnostics could never be null, and that's may not the best (or even valid) way to do it.

View 1 Replies

MVC :: Passing Objects Between View And Controller?

Sep 2, 2010

I would like to pass List<SelectListItem> (not selected item but the whole "List" object) back to controller.

for example in my GET controller i would have this

ViewData["list"] = some select list from repository;

then on post I would like to get the list back from view..pretty much i'm trying to use ViewData["list"] as storage..this way I would use ajax to remove or add items to/from the list.

View 10 Replies

MVC :: Passing 3 Objects In Edit Form?

Apr 1, 2011

I have an Edit form that utilizes the following ViewModel:

[Code]....

SUserDetail, User and CUDetail are LINQtoSQL classes in my [ .dbml ]. What the above ViewModel allows me to do, is provide a nice and neat Edit form populated with data from the above 3 objects.

However I am stuck on how to handle the HTTP Post for the Edit Action.

View 5 Replies

Architecture :: Passing Objects Between Aspx Pages?

Jan 21, 2010

I have an application that uses DataContracts/DataMembers and Serialization to store information entered in a tab control. There are 8 tabs in the control (therefore 8 aspx pages). The final tab is used to write the information to disk.I am trying to understand: When should serialization be used in a web app? The objects are stored in memory not on disk. Is this another means of passing objects between aspx pages? If so when should serialization be used vs. session objects? How long is the serialized object retained in memory?Can I get a simple example of how to serialize in one page and deserialize the object in another page?I've read many blogs regarding serialization but have yet to find a simple example and none of them explain when serialization should be used vs. session objects?

View 3 Replies

MVC :: Passing A List Of Entity Objects To View From Controller?

Aug 5, 2010

I need to pass a list of Entity Objects from Controller to View but not put it in the Model context. It is the users homepage, but I am putting a list of alerts on the users home page(somewhat like facebook). So I need the User Context as the Model I pass but need to pass the Alert model as well so I can show the list of alerts.. How would I do that? The code below is what I have so far..

UserController

[Code]....

UserRepository

[Code]....

View 1 Replies

MVC :: Passing A List Of Objects From View To Controller Via Jquery Ajax?

Jan 22, 2010

I have a form that I don't want to post back so I need to get the form values into my controller via jquery's ajax method.Here is my test controller method:

[Code]....

When I debug the controller method and look at the lineItems parameter, it always contains 0 items. I've tried various formats for the javascipt lineItems parameter but still 0 items. I'm also open to some other way of getting these values in like the jquery form serialze method or something else.

View 2 Replies

Asp.net - Equivalent To IScriptControl For Web.UI.Page?

Apr 1, 2010

We've been using IScriptControl to tie javascript objects to our UserControls and ServerControls, and it's worked fine.The problem is that ASP.NET seems to provide no method to tie a javascript object to a Page. Up to now, we've been putting plain functions in the global namespace, but I am developing a serious allergy to that practice.It'd be easy enough to wrap our functions into a javascript class, and to include the javascript file on the page, but how to instantiate the object, how to reference it from callback events, and how to pass data to it from the code-behind, I haven't figured out.Or rather, the methods we've been using up to now (hidden fields, emitted javascript strings, etc.

View 1 Replies

AJAX :: Inheriting From ServerControl That Uses IScriptControl

Mar 30, 2010

I've written a ServerControl that contains a significant amount of javascript, and I'm using IScriptControl to pass parameters from the server code to the javascript. The javascript file is configured as an embedded resource, and a script reference to the file is being injected into the html by IScriptControl.GetScriptReferences(). The ServerControl is contained in a DLL assembly. When I use the control in a test page everything works fine.

What I want to do is to extend the control - to derive a new control from it, in a second assembly, that provides some extended functionality. (The first assembly contains code that is shared across customers, the second code that is shared across several projects for the same customer). So, my problem: I create a new ServerControl that derives from the first, but doesn't yet provide any new functionality.

[Code]....

Then I change my "<%@ Register ... %>" tag in the test page to reference the derived control. Things compile just fine, and the code-behind runs fine, but I get an undefined variable error in javascript. Sys.Application.add_init() is calling $create(), passing the <namespace>.<classname> of the javascript class, and it's throwing an error on the namespace.

Now, the namespace is registered on the first line of javascript file. Which makes it look like the javascript file might not be being included, when using the derived control. So I stuck a "debugging" line in front of the Type.registerNamespace(). Using the base control, the debugger breaks as it should. Using the derived control, it does not.

So, I look at the script includes in both versions of the page. They are identical. The sources are src="/testing/WebResource.axd?<random junk>", or src="/testing/ScriptResource.axd?<random junk", so I'm not sure which one refers to my embedded javascript file, but whichever one it is, the includes are identical between the page using the base control that works and the page using the derived control that does not.

View 1 Replies

MVC :: - View - Passing Multiple Objects To The View And Selecting Data From The Lists?

May 17, 2010

I have a view which takes two objects: booking and list of reasons for canceling that booking.I have two classes: clsBooking, clsBookingCancelationReason I can read both objects in my view - no problems there. After I read the objects, I display the booking details and I generate a list of cancelation reasons in the following way:

[Code]....

The code above generates a list of cancelation reasons.How do I pick up the selected ReasonId from the list?
I need to generate a link that will contain the bookingId and the selected reason for canceling the booking.I can get the bookingId out easily since it's stored in the Model...but how do I go about the selected ReasonId?

View 5 Replies

Custom Server Controls :: Accessing Embedded Resource From IScriptControl?

Dec 1, 2010

My Composite control implements IScriptControl interface.

ScriptReferences java script file does the client-side work, there I want to load a html file inside iFrame.

The Html file is an embedded resource:

([assembly: System.Web.UI.WebResource("Control.Resources.list.htm", "text/html")])

I pass the path of the html to the javascript file via descriptor property:

IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
{
descriptor.AddProperty("iframe", iframe);
return new ScriptDescriptor[] { descriptor };
}

Where iframe is a string that contains the path from the webresource.

Now, in this html file I want to display few images that must be also loaded from resource.

The Question is how to access the resources from this html file?

Do I have to pass every image path as descriptor property?

View 10 Replies







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