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!!
Just a quick one, seems pretty weird to me.
I installed .net 4.0 on an old IIS6 box, ready to deploy a asp.net mvc app targeting .net 4.0. I thought, which to me seems logical, that I install .net 4.0, setup a new web site, new app pool, set the web site to asp.net 4.0 (other configuration also needed to run MVC on IIS6 here and here) and it would just work.
Errr… No. The page cannot be displayed! Nothing to do with MVC.
Apparently just because you have installed .net 4 and the option is available in IIS, it’s not enabled. I’m not going to repeat anything here…take a look at this post – clear, easy steps on exactly what you need to do and how to check if this is the problem.
You may come up against this little error when working on a MVC application, I specifically find things like this crop up when you are upgrading from previous version e.g. VS 2008 to 2010 and the like.
They are a complete pain in the bum quite frankly, you can spend hours googling around, trying this trying that, posting questions here and there etc etc…so I’m adding to the this and that which you will of course try, because it’s the sort of error you don’t care about…it’s just getting in the way of your day!
There would seem to be some kind of issue with MvcBuildViews and this error http://goo.gl/ogo1e
Anyway, what worked for me was to delete the debug directory from within the obj directory and it all worked…
Hopefully this will help someone else!! Or at the very least be something else to try on the way to solving another time wasting issue!!
UPDATE: May have been a bit hasty in my excitement of solving this…its really only part solved as I find i have to delete the debug directory every time I want to publish/package!
Hey, I need some advice/help, now I’ve been writing on this blog for a few years, I don’t blog a great deal in comparison to many of my peers and my blog doesn’t get a massive number of hits, BUT I seem to get a fair share of comment spammers!!
I have image verification on the comments and I have put an Akismet API key into the Geekswithblogs settings, but I still get a bunch of spam comments.
They could almost be real, until you see the link going off to some dating site or casino crap.
What does everyone do?? Delete them every time?? Moderate comments??
I would rather not moderate comments if possible, but is that the only way to stop the crap??
As Visual Studio 2010 IDE has been mostly written in WPF, extending the start page has become pretty darn easy and I for one find this quite interesting as I always open with the start page and the more customisation I can have the better!
There are a few things you will need to install first to get going
- Visual Studio 2010 SDK
- Start page project template, which you can either get from the New Project dialog, in the online gallery section in VS or download from here
I was going to write a blog post on how to create a custom start page, but decided that msdn have done such a good job I was pretty much wasting my time, so take a look here, it has in detail everything you need to know to get it done! :)
If for some reason you need to specify a specific connection string for a DataContext, you can of course pass the connection string when you initialise you DataContext object. A common scenario could be a dev/test/stage/live connection string, but in my case its for either a live or archive database.
I however want the connection string to be handled by the DataContext, there are probably lots of different reasons someone would want to do this…but here are mine.
- I want the same connection string for all instances of DataContext, but I don’t know what it is yet!
- I prefer the clean code and ease of not using a constructor parameter.
- The refactoring of using a constructor parameter could be a nightmare.
So my approach is to create a new partial class for the DataContext and handle empty constructor in there.
First from within the LINQ to SQL designer I changed the connection property to None. This will remove the empty constructor code from the auto generated designer.cs file.
Right click on the .dbml file, click View Code and a file and class is created for you!
You’ll see the new class created in solutions explorer and the file will open.
We are going to be playing with constructors so you need to add the inheritance from System.Data.Linq.DataContext
Add the empty constructor and I have added a property that will get my connection string, you will have whatever logic you need to decide and get the connection string you require. In my case I will be hitting a database, but I have omitted that code.
Now when I new up my DataContext, I can just leave the constructor empty and my partial class will decide which one i need to use.
Nice, clean code that can be easily refractored and tested.
Share this post :