IJavaScriptObject in the new version

Posted by: Ajax.NET Professional, on 22 Oct 2005 | View original | Bookmarked: 0 time(s)

With the new version you are able to get the real JavaScript wrapper objects that are used internal to representate the JavaScript objects. This will allow you to post any object from the client-side JavaScript code you want that does not exist as a CLR type:

<script type="text/javascript">

function test()
{
 var o = new Object();
 o.FirstName = "Michael";
 o.Age = 28;

 var res = AJAXDemo.WebForm1.GetAnyJavaScriptObject(o);

 alert(res.value);
}

</script> 

On the server-side code you can access each object:

[AjaxMethod]
public string GetAnyJavaScriptObject(IJavaScriptObject o)
{
  if(o is JavaScriptArray)
    return "array";
  else if(o is JavaScriptBoolean)
    return "boolean";
  else if(o is JavaScriptNumber)
    return "number";
  else if(o is JavaScriptString)
    return "string";
  else if(o is JavaScriptObject)
    return "object";
   
  return null;
}

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1824 | Hits: 143

Similar Posts

  • Introducing SharePoint 2010 Training at U2U more
  • Welcome the WebUI Test Studio v2.0! more
  • New Entity Framework Feature CTP for VS2010 Beta 2 more
  • Telerik OpenAccess ORM introduces the industry-first full support for SQL Azure and extends functionality more
  • Visual Studio Extensions for RadControls for Silverlight Coming with Q3 2009 Release more
  • How to: Validate data with SL/WPF RadGridView Part I validating on property/cell level via Data Annotations more
  • Sneak Peak: CSS Sprites Make Your Websites Faster more
  • Get Ready for Teleriks Custom-built Extensions for ASP.NET MVC more
  • View and print Reporting Services Reports from Silverlight. more
  • Telerik OpenAccess WCF Wizard October CTP more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD