Contents tagged with .NET 4.0
The problem seems to be when using a background style, it takes out the space between the image url close bracket and the next style.
Not a problem in IE 9 or chrome (haven’t tested others).
So I set about researching the problem and found nothing…struggled a bit getting the search term right and clearly never mastered it as I found zip.
Not to be put off, I was looking at the YUI compression tool from Yahoo, said to be better…but needs the java runtime and seems to complex to simply use, certainly for my simple taste!
Then I found a YUI .net implementation on codeplex. Excellent, its was even in NuGet.
However…I wanted it as a build task to run in VS, I don’t really want to think about this stuff more than once.
So I wrote a little command line wrapper for it. Excellent. Even got ILMerge involved to merge the YUI dll’s into my exe. I know there are ways to use Reflection to load dll’s as embedded resources…but I didn’t fancy doing that!
I did look at using CommandLine (also on codeplex) as I have done before, but ILMerge does not like that. Don’t take my word for it, but it seems to be something to do with ILMerge is .net 2 and CommandLine uses some .net4 features. It wasn’t happy…anyway, I just wrote a few lines of code to parse the command line args myself.
It’s not complex or very flexible, but is very suitable to my needs.
You can pass in an array of files to minify and a target path. That’s it. It’ll merge the files if you pass more than one…you have no choice!
> SCmin.exe –s C:\big.css C:\big1.css –t C:\small.css
// This will take big.css and big1.css and put it into small.css
Download the exe or full source.
There are a million plugins for jQuery and when a web forms developer like myself works in MVC making use of them is par-for-the-course! MVC is the way now, web forms are but a memory!!
Grids / tables are my focus at the moment. I don’t want to get in to righting reems of css and html, but it’s not acceptable to simply dump a table on the screen, functionality like sorting, paging, fixed header and perhaps filtering are expected behaviour. What isn’t always required though is the massive functionality like editing etc you get with many grid plugins out there.
You potentially spend a long time getting everything hooked together when you just don’t need it.
That is where the jQuery DataTable plugin comes in. It doesn’t have editing “out of the box” (you can add other plugins as you require to achieve such functionality).
What it does though is very nicely format a table (and integrate with jQuery UI) without needing to hook up and Async actions etc.
Take a look here… http://www.datatables.net
I did in the first instance start looking at the Telerik MVC grid control – I’m a fan of Telerik controls and if you are developing an in-house of open source app you get the MVC stuff for free…nice! Their grid however is far more than I require.
Note: Using Telerik MVC controls with your own jQuery and jQuery UI does come with some hurdles, mainly to do with the order in which all your jQuery is executing – I won’t cover that here though – mainly because I don’t have a clear answer on the best way to solve it!
One nice thing about the dataTable above is how easy it is to extend http://www.datatables.net/examples/plug-ins/plugin_api.html and there are some nifty examples on the site already…
I however have a requirement that wasn’t on the site … I need a grid at the bottom of the page that will size automatically to the bottom of the page and be scrollable if required within its own space i.e. everything above the grid didn’t scroll as well. Now a CSS master may have a great solution to this … I’m not that master and so didn’t! The content above the grid can vary so any kind of fixed positioning is out.
So I wrote a little extension for the DataTable, hooked that up to the document.ready event and window.resize event.
Initialising my dataTable ( s )…
My extension to the API to give me the resizing….
This is very much is debug mode, so pretty verbose at the moment – I’ll tidy that up later!
You can see the last call is a call to an existing method, as the columns are fixed and that normally involves so CSS voodoo, a call to adjust those sizes is required.
Just above is the style that the dataTable gives the grid wrapper div, I got that from some firebug action and stick in my new height.
The –83 is to give me the space at the bottom i require for fixed footer!
Finally I hook that up to the load and window resize. I’m actually using jQuery UI tabs as well, so I’ve got that in the open event of the tabs.
And that all there is too it. Testament to the wonders of jQuery and the immense community surrounding it – to which I am extremely grateful.
I’ve also hooked up some custom column filtering on the grid – pretty normal stuff though – you can get what you need for that from their website. I do hide the out of the box filter input as I wanted column specific, you need filtering turned on when initialising to get it to work and that input come with it! Tip: fnFilter is the method you want. With column index as a param – I used data tags to simply that one.
OK, so for some reason you have a mega mashup solution with ASP.net AJAX, jQuery and web forms.
Perhaps you are just on the migration from AjaxControlToolkit to the jQuery UI framework – who knows!!
Anyway, the problem is that when you post back with something like an UpdatePanel, you will find that your nicely setup jQuery stuff, like the datepicker for example will no longer work.
You may have something like this…
When you’re ASP.net UpdatePanel post back, you will find that your datepicker has gone. Bugger!
Well you need to add this little gem to set it back up again once the UpdatePanel comes back to the page.
Your choice…you have the power
Share this post :
If you are using MVC it might be worth checking out the telerik controls (http://demos.telerik.com/aspnet-mvc), they are free if you are doing an internal or “not for profit” application.
If however you do choose to use them, you could come up against a little problem I had. Using the telerik controls with your own custom jQuery. In my case I was using the jQuery UI dialog.
It kept throwing an error where I was setting my div to a dialog.
The problem is when you use the telerik mvc stuff you need to call ScriptRegistrar
By default this adds a reference to jQuery and if you have already added a reference to jQuery because you are using it elsewhere, this causes a problem.
I found the solution here
And it was to change the above ScriptRegistrar call to this…
If you come across this one on stackoverflow it wont work – in my case the HtmlEditor would render no problem, but was unusable. Which is the same as someone else found when using the tab control – they went to the bother of re-writing the ScriptRegistrar. Not for me that one!!