Monday, June 9, 2014

format Jquery autocomplete result set

If you want to customize the appearance of the jQuery autocomplete suggestion result set, you have to replace the _renderItem function with your own creation that produces the desired result. The function definition will be as follows.

 $(function () {

 $.ui.autocomplete.prototype._renderItem = function (ul, item) {
            item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "$1");
            return $("
  • ")
                        .data("item.autocomplete", item)
                        .append("" + item.label + "")
                        .appendTo(ul);
            };

    //attach your autocomplete to the textbox. See my previous post http://ssenarath.blogspot.com/2014/06/jquery-autocomplete-suggest-size-is.html
    $("#ContentPlaceHolder1_txtDesignation").autocomplete({
     ...
    });

    });

    A complete discussion of similar topic can be found in http://stackoverflow.com/questions/2435964/jqueryui-how-can-i-custom-format-the-autocomplete-plug-in-results

    Cheers
    Samittha

    Thursday, June 5, 2014

    Jquery Autocomplete suggest size is displayed larger than the textbox

    When you use Jquery to make an autocomplete, IE displays the width of the suggest window lager than the input box.To make the suggestion window smaller you can apply code as shown below.

     $(function () {

     $("#txtSearch").autocomplete({
                source: function (request, response) {
                    $.ajax({

                        contentType: "application/json; charset=utf-8",
                        dataType: 'JSON',
                        url: '../SearchEmployee.asmx/GetEmployeeSuggestionList',
                        type: "POST",
                        data: '{empCode: "' + request.term + '"}',
                        dataType: "json",

                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item,
                                    value: item
                                }
                            }))
                        }
                    });

                }            minLength: 1,
                open: function(event, ui)
                {
                    $("#ctl00_cphMobileMainContent_txtSearch").autocomplete("widget").css("width", "300px"); 
                }       
     });
    });

    cheers
    Samitha

    Tuesday, May 13, 2014

    SQL Server Debugging with WinDbg

    Debugging in Server is a on of the concerns for modern developers. The following articles reveal information about a tool that can be used in SQL Server Debugging and what are the reasons for choosing it.

    http://www.sqlservercentral.com/blogs/aschenbrenner/2014/05/05/sql-server-debugging-with-windbg-an-introduction/

    Cheers
    Samitha

    Sunday, April 27, 2014

    Sql server Extended Events (video)

    Sql server  Extended Events  replaces Server Side Traces and its very lightweight.

    watch video
    http://www.brentozar.com/archive/2014/04/introduction-extended-events/

    Friday, April 11, 2014

    Colorize Crystal reports Controls

    If you have ever come across a situation where you need to colorize Crystal reports controls using Hex color values, there are few options you can choose between.
    1) Convert the color code to Hex in the sql using a funtion
    2) Convert the color code to Hex using a Crystal Reports custom function

    Following post provided step-by-step instructions on colorizing crystal report controls using a Crystal Reports custom function.

    http://www.paulspatterson.com/crystal-report-functions-to-colorize-background-using-html-hex-color-value/

    Cheers
    Samitha

    Saturday, March 22, 2014

    Redirect to new window using Reponse.Redirect

    We all know that we can use JavaScript's window.open method to open a new window.  I was curious if there is to achieve this from the code behind.  The answer is you can and there are various ways you can use depending on the requirement.

    I did it by using writing an extension method  to Reponse.Redirect as shown below.
    public static class ResponseHelper
    { 
    public static void Redirect(this HttpResponse response, 
    string url, string target, string windowFeatures) 
        { 
    
            if ((String.IsNullOrEmpty(target) || 
    target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && 
    String.IsNullOrEmpty(windowFeatures)) 
            { 
                response.Redirect(url); 
            } 
            else 
            { 
                Page page = (Page)HttpContext.Current.Handler; 
    
                if (page == null) 
                { 
                    throw new InvalidOperationException("Cannot 
    redirect to new window outside Page context."); 
                } 
                url = page.ResolveClientUrl(url); 
    
                string script; 
                if (!String.IsNullOrEmpty(windowFeatures)) 
                { 
                    script = @"window.open(""{0}"", ""{1}"", 
    ""{2}"");"; 
                } 
                else 
                { 
                    script = @"window.open(""{0}"", ""{1}"");"; 
                }
                script = String.Format(script, url, target,
     windowFeatures); 
                ScriptManager.RegisterStartupScript(page, 
    typeof(Page), "Redirect", script, true); 
            } }
     }

    usage
    Response.Redirect(redirectURL, "_blank", 
    "menubar=0,scrollbars=1,width=780,height=900,top=10");
    This has been originally suggested in the following post. The post dscusses various ways you can achieve the same functionality.
    http://stackoverflow.com/questions/104601/response-redirect-to-new-window
     Cheers
    Samitha

    Saturday, March 1, 2014

    HTML 5 Readiness

    The following site is a valuable resource of indicating the HTML 5 readiness of popular browsers and how they have evolved over the years.

    http://html5readiness.com/

    Cheers
    Samitha