Home » jQuery » jQuery UI – Resizable w/ ASP.NET Themes

jQuery UI – Resizable w/ ASP.NET Themes

flwr-083 If you’ve been up to the jQuery web site and looked at the documentation for resizable() you probably thought, “hey, no problem, I can do that.”  Well, that’s what I thought, too, until I started using it.

Here’s what you need to know to get this all working–and specifically, what you need to know to get it working under ASP.NET.

First, as you would expect, you’ll need to create some HTML on a page that has a div tag that you can select with a jQuery selector statement.  I just gave mine an id of “sizeMe”:

    <form id="form1" runat="server">
    <div style="height:100%; width: 100%;">
    <div id="sizeMe">
        <p>Here is some text</p></div>

Then you’ll need to use the jQuery selector and call resizable() in the ready() handler:

$(function() {

And as they say on TV, “But wait, there’s more…”

Because the part we kind of glossed over in our work is that the jQuery UI has themes that you can apply.  This is a set of CSS files and images that we can copy into our ASP.NET app_Themes/themeName directory.  To style these widgets.  We need a theme so that the cursor will change for the edges and so that we get the grab handle in the corner of the div we’ve marked for resizing.

When you download the zip file from the jQuery UI site make sure you choose a style and you copy the stuff in the theme directory of the jQuery UI zip file into your theme directory of your ASP.NET web application.

You’ll notice that there several CSS files that are part of this set.  And you’d think that since they are in the theme directory that they’d automatically get sucked into any ASPX page we had attached to the theme.  Well, if that’s what you are thinking, you’d be wrong.

I don’t know if it’s by design or if it’s an “undocumented feature,” but it looks like any file that has multiple “.” in it will treat the first “.” as the starting point for the extension when .NET processes the files in the theme directory.  Because all of the jQuery CSS files are named ui.something.css, these files will not get sucked in automatically.

That’s actually good news because if it did suck them in for us, we’d end up sucking them in twice or we’d need to remove the us.all.css file.  But since they aren’t automatically processed, what we are going to do is place the following statement in the top of our main css file for our web site:

@import "ui.all.css";

And that folks, is the magic that makes this all work under ASP.NET.

Once you have the themes installed correctly, the HTML and javascript will do their thing and you can finally resize your div like you would expect to be able to.

I also note that it is pretty cool that jQuery themes work so nicely with ASP.NET themes.  This means that just by switching theme directories at the ASP.NET level we can switch our jQuery UI themes as well.


Other post in jQuery

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • jQuery – Using Slider as a ScrollbarjQuery – Using Slider as a Scrollbar Last week I introduced the jQuery UI element known as a slider and indicated that this control could easily be used as a custom scrollbar. Today I'm going to show you exactly how that's […]
  • jQuery – DialogjQuery – Dialog Ever since pop-up windows became “evil” in the web development world, developers have been looking for other ways to achieve the same effect.  The most common method is to use some […]
  • jQuery – Date PickerjQuery – Date Picker Today we’ll start taking a look at the final control in the jQuery UI suite.  The Date Picker. This control, as with all the other controls we’ve looked at, is relatively simple […]
  • if IE Conditional CSS using ASP.NET Themesif IE Conditional CSS using ASP.NET Themes Yesterday when I introduced Artisteer I mentioned that they use conditional link comments to include IE6 and IE7 specific CSS in the master page. In my world, I like to use ASP.NET […]
  • jQuery – Retrieving HTML FragmentsjQuery – Retrieving HTML Fragments A couple of weeks ago I mentioned that I had built a tooltip using jQuery.  We focused mostly on the positioning of the tooltip at the time because, historically, that's where most of the […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.

One Pingback/Trackback

  • Pingback: Dew Drop - February 18, 2009 | Alvin Ashcraft's Morning Dew()

  • Ted

    Hi, Thanks for the info…

    When you say
    @import ui.all.css

    Do you mean @import ui.*.css

    Not sure…

    I was looking for help as it seems whenever I edit source/markup in VS 2008 my project seems to cycle through loading all the .css file’s over a few times– it’s a bit of a problem when editing a site via my wireless connection. I have to wait while all the .css files are reloaded over and over.

    I’m loading jquery from my masterpage (.NET 3.5 SP1 + JQuery intellisense hotfix) via the scriptmanager, I’m having trouble in VS 2008 with JScript intellisense error (within the jquery-1.3.2.js file also)

    I’m also using App_Themes\MyTheme etc to house all my .css

    The website works fine, just a bother in VS-2008.

    I think the fact that there’s an Intellisense error in the jquery-1.3.2.js file is causing to problem. It’s as if all my .css files are not cached and every time I edit a page, it looks to reload my .css files.

    Any ideas?

    Should I not use Scriptmanager to load the JQuery/JQueryUI and blockUI ?

  • Dave

    No, I meant what I wrote. But I wrote this prior to jquery 1.3.x so you may not have an ui.all.css file anymore. Last time I got the CSS for the UI stuff it was all in one CSS file. The only reason for the import statement is because VS2008 can’t see css files that have dots prior to the css extension. So, it won’t load them automatically.

    You should be developing on your local machine. Not on some other computer over the Internet.

    No, I don’t use the script manager.

    I have seen the intellisense error on one of my computers but not my main one. I’m not sure what the fix is yet but I’m quite sure it has nothing to do with CSS. In fact only jquery ui uses the CSS.