Contents tagged with AJAX

  • MIX10 Big Announcements Speculation

    What’s your speculation on the big announcements to come from MIX10? A date for VS 2010 availability on MSDN? A release candidate for Silverlight 4 on the desktop? An SDK for Silverlight on Windows Mobile 7? A CTP of Internet Explorer 9? Something (anything!) new on Windows Live ID development? More JQuery in ASP.NET?


  • Fixing EntityDataSourceWrapper Error in EF (VB Version)

    I lost a lot of time today on this error:

    ‘EntityDataSourceWrapper' does not contain a property with the name …'

    The project is ASP.NET 3.5 using Entity Framework and VB. I’m using the Telerik RadControls for ASP.NET AJAX (a sweet suite!). In my app, clicking a row’s Edit button on the RADGrid  opens the popup Edit form for updating the data.

    It seemed like a simple task to get the DataItem for the row (item), extract a value, and use that value as the SelectedValue of radiobuttonlist.  It turns out that you need heroic measures to get a value out of e.Item.DataItem in Entity Framework! Sheesh!

    Here’s the VB version of LinqHelpers as posted by Diego B Vega. It noses around in the DataItem to return a TEntity (whatever that is!). I’m still trying to figure this code out, but at least I’m productive again!

    ' LinqHelpers.vb - Put it into the App_Code folder
    Namespace LinqHelpers
        Public NotInheritable Class EntityDataSourceExtensions
            Public Shared Function GetItemObject _
            (Of TEntity As Class)(ByVal dataItem As Object) As TEntity
                Dim entity As TEntity = TryCast(dataItem, TEntity)
                If entity IsNot Nothing Then
                    Return entity
                End If
                Dim td = TryCast(dataItem, ICustomTypeDescriptor)
                If td IsNot Nothing Then
                    Return DirectCast(td.GetPropertyOwner(Nothing), TEntity)
                End If
                Return Nothing
            End Function
        End Class
    End Namespace

    Once you’ve got a way to mess around inside the DataItem, you can fix up the radiobuttonlist (a dropdownlist would be similar). Do this in the RadGrid’s ItemCreated event as shown:

    Protected Sub RadGrid1_ItemCreated _
      (ByVal sender As Object, ByVal e As  _
       Telerik.Web.UI.GridItemEventArgs) _
       Handles RadGrid1.ItemCreated
        ' Sets the selected values for radiobuttons and
        ' ddls when displaying the edit form
        If (TypeOf e.Item Is GridEditFormItem) And _
            e.Item.IsInEditMode And _
            (Not IsNothing(e.Item.DataItem)) Then
            ' Get a reference to the editformitem
            Dim editFormItem As GridEditFormItem = _
            CType(e.Item, GridEditFormItem)
            ' Get the entity that's being used
            'with this screen (requires a LINQ helper)
            Dim entity = LinqHelpers.EntityDataSourceExtensions. _
            GetItemObject(Of CMS_Item)(e.Item.DataItem)

            ' Get a reference to the radiobutton list
            ' and set its value
            Dim rbl As RadioButtonList = _
            rbl.SelectedValue = entity.ItemType

            ' Get a reference to the Product radiobutton
            ' and set its value
            rbl = editFormItem.FindControl("radProduct")
            rbl.SelectedValue = entity.Product.ToString()

            ' Set the Stocked radiobuttonlist
            rbl = editFormItem.FindControl("radStocked")
            rbl.SelectedValue = entity.Stocked.ToString()

         End If
    End Sub

    Thanks to all the community contributions that help solve these issues. Here’s a thread with an answer by Microsoft’s Diego B Vega that got me over the hump:

    Am I the only one who spins on these things???




  • Review: Advanced ASP.NET AJAX Server Controls For .NET 3.5

    Advanced ASP.NET AJAX Server Controls For .NET 3.5 is a fine resource for ASP.NET developers who want to build high performance, data-driven Web applications with a richer user interface. The introduction of ASP.NET AJAX 2.0 extensions caught many of us off-guard. We were suddenly thrown into intensive JavaScript programming on a Microsoft platform. Faced with a major learning curve, many of us fled to the convenience of the UpdatePanel control as a stepping stone.

    There's no getting around it, it's going to take effort to get to the next level of AJAX capabilities using Microsoft's library. This book takes you into that journey - but not necessarily by the most direct route.

    The first third of the book feels more like a solid ASP.NET AJAX reference than a "how-to-do-it" tutorial. The early chapters cover the library's types, namespaces, and classes in depth. It just seemed too early and too dry to be dealing with the nitty-gritty of the platform.

    In my view, the book should start at Chapter Five. That's where you really make use of client-side functionality by adding it to server-based controls. As the authors point out, the AJAX library extensions help you overcome inconsistencies among browsers. You learn practical steps such as adding script resources, configuring ScriptManager, and getting into extender controls. The book leads you through the creation of an Image control extender that loops through a series of images at runtime. It's in this hands-on chapter that you really start to grasp the concepts. There's a substantial chapter of localization in ASP.NET AJAX. If you're taking on a translation, it would certainly be worth the price of the book.

    At the outset, I referred to the UpdatePanel. It could be called the "lazy developer's AJAX control". What I learn from Chapter 7 is that the UpdatePanel can be a real headache for control developers. The authors warn of unexpected problems when your carefully-crafted control finds itself inside a partial postback environment.

    The book's coverage of the asynchronous consumption of web services is solid. The authors go into all the important acronyms such as REST, and explain WCF from many angles including creating data contracts and service contracts.

    In the chapter on Application Services, I discovered how much I didn't know about the client-side use of ASP.NET's Membership, Role, and User Profile services. If these AJAX extensions to the server-side API's escaped you too, you'll really benefit from the chapter.

    Every ASP.NET developer knows about the AJAX Control Toolkit but Calderon and Rumerman take it further. They explain the overall architecture and then dig into how you can harness the Toolkit (and especially its animation support) in your own controls.

    In summary, this is a very good book for learning to write your own AJAX controls. My main complaint is that the cart comes before the horse... You want to dig into building something interesting (call it 'instant gratification' if you wish) but need to wade through several chapters of dry architectural and reference-type information.



  • Set a Validator's Display to 'None' for the ValidatorCalloutExtender

    If you look at Figure 15-1 in ASP.NET 3.5 For Dummies, you'll notice that there's an almost-hidden question mark (?) behind the AJAX Control Kit's ValidatorCallout control. The arrow in the picture points to the mistake (bug) in the book.


    At the time I took the screenshot, I couldn't figure out how to get rid of the underlying validator's error message text. I left the question mark with the intention of getting back to it but I never did.

    I figured out the problem by the time I shipped the book's source code...

    The trick is to set the validator control's Display property to 'None' so the error text doesn't appear. However, the control kit's callout still picks up the text and uses it. I know it seems obvious, but I was just implementing the same validation for a client's application and had trouble recalling the technique.

    So, here's the code to remind myself and anyone else how to deal with the built-in validator and the ValidatorCalloutExtender at the same time:

    <asp:TextBox CssClass="TextBox" Width="200px" ID="txtUserName" 
        runat="server" TabIndex="1">
    <asp:RequiredFieldValidator ID="rqdUserName" runat="server" 
        ErrorMessage="The user ID (an email address) is required." 
        ControlToValidate="txtUserName" Display="None" >
    <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" 


  • Need an iPod-like Menu for ASP.NET Pages

    Do any of the ASP.NET component vendors have a treeview or menu control that emulates the look and feel of the iPod menu? Has anyone out there built one?

    I have a client who would like to save space by letting users drill down deep to their data without the need for an ever-widening treeview.

    The picture below (linked to Apple's site) shows the idea... except that each screen replaces the one before - there's no cascading.