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


Saturday, February 8, 2014

using Google map inside update panel

I  have tried to use the Google Map inside an updatepanel and it ended up giving me strange JavaScript error "javascript - Unable to get value of the property 'offsetWidth': object is null or undefined ".
After some research I found that it occurred when you have build your map when the Maps API JavaScript has not loaded. I as able to solve the issue when I load the map as displayed below.

 <script type="text/javascript">
        function initialize() {
            var mapOptions = {
                zoom: 6,
                center: new google.maps.LatLng(7.0000, 81.0000),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(document.getElementById("googleMap"), mapOptions);
        
            });
        }

        function loadScript() {
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "http://maps.googleapis.com/maps/api/js?key=<your_api_key>&sensor=false&callback=initialize";
            document.body.appendChild(script);
        }

        window.onload = loadScript;
    </script>

for more information refer http://stackoverflow.com/questions/5478450/google-map-error-a-is-null

Cheers
Samith

Saturday, January 11, 2014

Using Google MAP control in Asp.Net

There are various Google MAP controls available that can be used with Asp.Net. Listed below are few of popular Google MAP controls available.

1) Subgurim google map
2) Artem google map
3) Reimers google map

 I have tried using all of the above controls but my exact retirement could not be achieved. My objective was to get the latitude  and longitude of the clicked location. The problem was I had two map controls on the same form and it seems if two map controls are used on the same form, click event of the second control does not get fired for some reason. I could not find the reason for this to occur and finally ended up using google API provided in w3shools which solved my problem.

cheers
Samitha


Thursday, December 19, 2013

Change Asp.net Ajax tab page header from javascipt

This is not as straightforward as you might have thought. To access the tab pages use get_tabs()[indexOfTab] as shown below.

$find('ctl00_cphMainContent_tc1').get_tabs()[0]) ; // tab 0
$find('ctl00_cphMainContent_tc1').get_tabs()[1]) ; // tab 1

To set the tab header use the _header of the tab
 $find('ctl00_cphMainContent_tc1').get_tabs()[0]._header.innerHTML='Tab 0';
 $find('ctl00_cphMainContent_tc1').get_tabs()[1]._header.innerHTML='Tab 1';

Cheers
Samitha