Monday, August 31, 2015

ASP.NET MVC HttpContext.Current.Server.MapPath null for WCF Webservice


Just solved a problem at work:

If HttpContext.Current.Server.MapPath is giving you null or an exception or not working, there are several possibilities. One of them is you didn't enable compatibility mode.

Better off to migrate to another way of finding the server path than depending on HttpContext though,

HttpContext is bad to depend on, when dealing with WCF or non-MVC applications (there isn't always a context.)

Hope this helps someone

~ B

Saturday, August 8, 2015

jQuery UI Dialog Create Custom Close Button


Just wanted to share how to create a custom close button with jQuery UI's Dialog Widget

Create a dialog this way

// TODO store modalDialog somewhere so you can call modalDialog.dialog('open'); and modalDialog.dialog('close'); when required

I suggest creating a wrapper JavaScript class, to store the dialogs by some id. That way you can retrieve dialogs already created. Some basic functions like wrapper.closeDialog(id), wrapper,createDialog(id) and so on will go a long way.

The key is, when using the .dialog function, jQuery UI wraps the dialog in its own div (the $(this).parent().find(".ui-dialog-titlebar") line).

Hope this helps someone.