Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Friday, 16 September 2011

javascript or .js files not loading properly for static html file in chrome, firefox works fine in IE

Kind of feeling itchy since couple of weeks for not being able to find out why javascript or .js files not loading properly for static html file in chrome and firefox, but works absolutely fine in IE.

Ok now used browser debugging tools, IE show the .js files loaded successfully and works fine. But chrome/forefix shows script were loaded like gibberish (chineese,japanese something like that). Something fishy going on, but how would you find it. Ok tried some other static html files and works absolutely fine, but only the html generated using xsl is having the issue.

No luck, then suddenly felt something wrong with file. Ok opened the working file in notepad and have found this file is saved ASCII encoding. Now the buggy file its in unicode that's it.

IE loads all references in the format available by the file, but chrome/firefox tries to load based on the base file (.html file) which has

m eta http-equiv="Content-Type" content="text/html; charset=utf-16"

So modified xsl to output standard utf-8 format and job done.

Never trust anything that can think for itself if you can't see where it keeps its brain.
~J.K. Rowling

Tuesday, 13 September 2011

JQuery dialog inside update panel generating duplicate elements

JQuery dialog is a nice feature provided by JQuery UI, having said care should be taken when using dialog boxes inside an update panel.

Consider a dialog box is inside an update panel as shown below :-








Now javascript for displaying the dialog

var btnAddBloggerData= $("#btnAddBloggerData");
btnAddBloggerData
  .unbind("click")
  .bind("click", function () {
  this.disabled = true;
  $("#bloggerdata_dialogform").dialog("destroy");
  $("#bloggerdata_dialogform").dialog({
            autoOpen: true,
            modal: true,
            width: 500,
            buttons: {
                Cancel: function () {
                    $(this).dialog("close");
                },
                "Create": function (evt) {
                /*ajax call to update */
               }
            },
            close: function () {

            }
        });

});

All seems right and works fine. If this has been an asp.net server control (.ascx) would have completely weird behaviour. Each time a post back occurs a new dialog is added and finally there would be duplication of ids ie.. number of elements with id as "bloggerdata_dialogform" will increase for every postback.

Hence to resolve this issue do not use $("#bloggerdata_dialogform").dialog("destroy"); which is a killer. Now modify your script to

$.ready(function(){
   $("#bloggerdata_dialogform").dialog({
            autoOpen: false,
            modal: true,
            width: 500,
            buttons: {
                Cancel: function () {
                    $(this).dialog("close");
                },
                "Create": function (evt) {
                /*ajax call to update */
               }
            }
        });
});
var btnAddBloggerData= $("#btnAddBloggerData");
btnAddBloggerData
  .unbind("click")
  .bind("click", function () {
  this.disabled = true;
  $("#bloggerdata_dialogform").dialog("open");

});


So instead of destroying the element and use the same element for every postback.

Errors using inadequate data are much less than those using no data at all.
Charles Babbage

Monday, 12 September 2011

Visual studio 2010 run post build events based on debug or release mode

Using a batch file that should be run after post build is a common task. But some actions are not required in debug mode and some times in release mode.

To achieve this create 2 batch files
1. debugpostbuild.bat
2. releasepostbuild.bat

Update post-build event command line as follows:-
1. goto VS2010 -> right click on your project -> properties -> Build Events
2. copy below code

if $(ConfigurationName) == Release (
call $(SolutionDir)\debugpostbuild.bat
)
else (
call $(SolutionDir)\releasepostbuild.bat
)


That's it. so simple.

Any sufficiently advanced technology is indistinguishable from magic. ~Arthur C. Clarke

Thursday, 1 September 2011

Structure of jqGrid after generating html and its contents

Something which might be useful for everyone using jqgrid.

JQGrid HTML structure:




for short form refer to the following link stackoverflow.com.


Errors using inadequate data are much less than those using no data at all.
Charles Babbage

Wednesday, 24 August 2011

Formatting date in XSL using .NET standard formatting

Microsoft standard .NET date format can be used in xsl transform which is a key feature provided using msxsl:script Element.

The following snippet demonstrates using .NET "ToShortDateString" inside XSL transform:-


  
  

Above defined method "ToCSharpShortDateString" can be used as follows:-



Now that xsl is ready, lets use this with ASP.NET xml control . Code behind should look something like this.

XmlDocument doc = new Document(xmlPath);
 XPathNavigator nav = doc.CreateNavigator();
xmlData.XPathNavigator = nav;
string xslFileName = Server.MapPath("~/InvoiceReport.xsl");
xmlData.TransformSource = xslFileName;
xmlData.DataBind();


Technological progress has merely provided us with more efficient means for going backwards. ~Aldous Huxley

Thursday, 18 August 2011

jqGrid error at line $t.p.colModel[lvc].width += cr;

Recently I am getting an error in jqGrid plugin at the following line :-

$t.p.colModel[lvc].width += cr;


After debugging through the code this issue occurs with in the function
setGridWidth: function (nwidth, shrink)
.....
$t.p.colModel[lvc].width += cr;
.....

where nwidth is null

So while calling method setGridWidth on a grid make sure the width is a definite value and is greater than 0

Control is the wrong word. The practice is very much about sharing, and, in any creative practice, some individuals, whether partners or directors, are much closer to certain projects than I could ever be.
Norman Foster

Friday, 12 August 2011

Using SQL Server Compact with FluentNHibernate

FluentNHibernate is an alternative to NHibernate that supports Object Relational Mapping framework. Actually FluentNHibernate is build on top of NHibernate that provides strongly typed mapping using c# as opposed to xml mapping (.hbm.xml).

SQL Server CE (Compact edition) is commonly used for small applications as this would not need any packaging and is a simple file copy.

Using FluentNHibernate with SQL Server CE 3.5 file has a flaw in which any changes to mapping would not be reflected in the database unless the database is re-created.

Now this has been solved in the latest version of SQL Server CE 4.0, where in any changes are automatically reflected in the database.

Here is code to configure SQL Server CE
MsSqlCeConfiguration sqlconfig = MsSqlCeConfiguration.Standard.ConnectionString(ConnectionString);
FluentConfiguration fc = Fluently.Configure();
fc = fc.Database(sqlconfig );
ISessionFactory sessionFactory = fc.Cache(c => c
   .UseQueryCache()
   .ProviderClass())
   .Mappings(m => m
   .FluentMappings.AddFromAssemblyOf())
   .ExposeConfiguration((NHibernate.Cfg.Configuration config) => new SchemaUpdate(config)
   .Execute(false, true))
   .BuildSessionFactory();




Telegraphs are machines for conveying information over extensive lines with great rapidity.
Charles Babbage


Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers