Sunday, November 01, 2015

Simple image slider using JQuery

following is the jquery code for image slider

   function showImage() {
            var shopImages = sessionStorage.getItem('shopImages');    // comma separated image paths         
            shopImage = shopImages.split(',');          
            $('#bg').css('background', 'url(' + shopImage[0] + ')');  // by default first image will be back ground image

            $('#ImageCount').text("1/" + shopImage.length);// show current image

                var step = 1;
                var current = 1;
                var maximum = shopImage.length;// maximum length  of Image collection
                var visible = 2;
                var speed = 200;
// right click increments
                $('#right').click(function () {
                    if (current + step <= maximum) {

                        current = current + step;

                        $('#bg').css('background', 'url(' + shopImage[current - 1] + ')');
                        $('#ImageCount').text(current + "/" + shopImage.length);
// left click decreases

                $('#left').click(function () {
                    if (current == 1) {

                        $('#bg').css('background', 'url(' + shopImage[0] + ')');
                        $('#ImageCount').text(  "1/" + shopImage.length);
                    if (current >1 && current> current - step) {
                        current = current - step;

                        $('#bg').css('background', 'url(' + shopImage[current-1] + ')');
                        $('#ImageCount').text(current + "/" + shopImage.length);

Thursday, March 05, 2015

Update text box with drop down list selected value in angular js


Angular Script

var app = angular.module('windowExample', []);
1) we used $http service to call rest api
2) please note we will update only when the request to api is successful

app.controller('ExampleController',function ($scope, $window,$http) {
3) the function updates the text box with selected value of dropdown list

var selelem=angular.element(document.querySelector("#txtselName"));

Html part
1) design div
div ng-app="windowExample" ng-controller="ExampleController" ng-show="true"
2) design drop down list
select  style="width:100px;"  ng-model="selval" x-ng-change="update(selval)"
option ng-repeat="country in Countries" value={{}}>{{}}  option

input type="text" id="txtselName"

Dot Net Developer Notes: Consume rest api from angularJS

Dot Net Developer Notes: Consume rest api from angularJS


Angular js Script

1) Here ngResource module is included to get $resource service

var app=angular.module('mymodule',['ngResource']);

2) We created service instance using factory 
3) please note web method here Weather and query string parameter is q
4) send resource parameters we used @placedetails parameter

return $resource("",{method:'Weather',q:'@placedetails'},{'query':{method:'Get'}});

5) Create a controller to access the service


6) create a function refresh to refresh the service
$scope.refresh= function()
var placedetails=$scope.placedetails;
$scope.weatherdata=data ;

7) Please note we passed resource parameter in the format q:placedetails
8) HTML part


Wednesday, June 13, 2012

While restoring a db in production server . I got a following issue

i tried to restored using wizard it failed
Error 3154: The backup set holds a backup of a database other than the existing database.

first i tried following sql command

FROM DISK = 'C:\BackupAdventureworks.bak'

It raised following error

Exclusive access could not be obtained because the database is in use.

Later i tried following sql script

no result same error



Friday, June 08, 2012

Case sensitive comparison in Sql server

to compare case sensitive fields in sql server u need to cast the fields to varbinary
then compare

for example


select * from tbluser

select * from tbluser

both of above queries will give same results


select * from tbluser

cast (username as varbinary(lengthof username field)=
cast('test' as varbinary(length of usrname field)

Friday, June 01, 2012

Yesterday i got a requirement as follows

As in the screen shot depending upon the selection in the radio button list I need to fill drop down, similar to cascading drop down lists I used Jquery ajax to call database. Following steps are used in developing functionality Step 1 Add using System.Web.Services; in the name space region Add attribute [WebMethod] above the method to fill data. example [WebMethod] function filldropdown() { // do db interaction to get data } Step 2 Add following javascript to web page $(document).ready(function () { $('#<%= rdbFormType.ClientID%> :input').click(function () { var selRad = $("input[@name=<%=rdbFormType.ClientID%>]:radio:checked").val(); if (selRad == 1) { $('#AssociatedForm'). css('visibility', 'visible'); var loc = window.location.href; loc = (loc.substr(loc.length - 1, 1) == "/") ? loc + "AddForm.aspx" : loc; $.ajax({ type: "POST", url: loc + "/" + 'methodname', data: "{}", beforeSend: function (xhr) { xhr.setRequestHeader("Content-type", "application/json; charset=utf-8"); }, dataType: "json", success: function (msg) { $('#<%= ddlForm.ClientID%>') .get(0).options.length = 0; $('#<%= ddlForm.ClientID%>') .get(0).options[0] = new Option("Select Form", "-1"); $.each(msg.d, function (index, item) { $('#<%= ddlForm.ClientID%>').get(0).options[$('#<%= ddlForm.ClientID%>').get(0).options.length] = new Option(item.Display,item.Value); }); }, error: function (res, status, ex) { alert('Not able to load Form Data'); } }); } else { $('#AssociatedForm').css('visibility', 'collapse'); } }); }); Step 3 Add following to the web.config add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" In following above steps you may encounter following errors Error 1) 500 internal server error while posting data to server fix : replace data: "{}" with data: {} Error 2) 200 +ok but it will return whole html design. Fix: check your database calling method is having keywords Public and static and also check whether step 3 is followed or not Error 3)Invalid postback or callback argument. A Event validation is enabled using in configuration or <%@ Page EnableEventValidation=”true” %> in a page. Â For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. Â If the data is valid and expected, use the ClientScriptManager. RegisterForEventValidation method in order to register the postback or callback data for validation. Fix: protected override void Render(HtmlTextWriter writer) { Page.ClientScript. RegisterForEventValidation (dropdownlistcontrol.UniqueID, value); base.Render(writer); }

Tuesday, May 29, 2012

 I found a e book for 70-515 Found at

Sunday, May 20, 2012

Hi Guys,

I cleared CSM. Now Certified Scrum Master. Its fun to work with agile methodologies.
Earlier i passed MCPD in 2008