Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

jQuery and the ConventionController

Well here’s a fine how-do-ya-do. I’m using the ConventionController from MVCContrib which means I have controls with IDs like dto.JobName and dto.OrderedDate.

Problem is, I can’t get at these things by ID in jQuery anymore. "#dto.JobName" in jQuery means (if my memory of CSS serves) select all elements with an ID of dto and a CSS class of JobName. Even if that’s wrong, it doesn’t matter much. The end result is $( "#dto.JobName" ) returns a useless object.

Current workaround is to select by name. Like so: $( "input[name=’dto.JobName’]" ) or $( "select[name=’dto.JobTypes’] ).

Kyle the Selector

This entry was posted in ASP.NET MVC, Javascript. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Kyle Baley

    @Mark: How do you mean? Selecting the item from the HTML document using an XPath statement? If so, I kinda like my workaround better.

    @Scott: Apparently so. The following works in both IE and Firefox:




    No dot
    With dot


  • http://lazycoder.com Scott

    Does Document.getElementById(“dto.JobName”); work?

  • http://www.marklennox.net Mark Lennox

    will xpath work instead? I haen’t tried that myself…

  • Kyle Baley

    @Joshua

    The Hillbilly is an enigma wrapped in a mystery covered with a smooth chocolatey coating.

    He’s also easily swayed. Patch has been submitted. And if I get firebombed by the Society of Programmers Who Use Underscores In Their Property Names, I’m blaming you. Those guys are pissed off with me enough as it is.

  • http://flimflan.com/blog Joshua Flanagan

    You’re willing to dive into the guts of an open source linq provider, but got scared away from trying to figure out how to fix the mvccontrib code so that an underscore is used instead of a period? Come on, Hillbilly Up!

  • http://www.kenegozi.com/blog Ken Egozi

    I *think* that a dot in id is not allowed. that’s why MonoRail helpers turn dots to underscores, and WebForms transforms dots to dollars. Well MS stuff turns everything into dollars though ..