Search This Blog

Thursday, October 18, 2012

Move elements from one list to another using jquery

This post will not help the C# gurus. Because they are already using this feature different techniques. But I hope this will be helpful for the PHP beginners :) . Now I am going to show you how you can move list items from one list box to another using simple jquery. Using jquery it is very simple than you think. :)

This is the Jquery portion:

 <script src="jquery-1.6.2.js"></script>

 <script>

 function move_forward()

 {

     //taking the selected items of list 1 and concatenating to a variable named forward_variable.

   var forward_variable='';

   $("#list1 :selected").each(function(){

       forward_variable+="<option value='"+$(this).val()+"'>"+$(this).html()+"</option>";

       $(this).remove();  

   });

     //Now appending the selected firs list's element to the list 2.

   $("#list2").append(forward_variable);

     //Sorting the list 2 so that it shows the list alphabetically

   sort_element("list2");

 }

 function move_backward()

 {

   var backward_variable='';

     //taking the selected items of list 2 and concatenating to a variable named backward_variable.

   $("#list2 :selected").each(function(){

       backward_variable+="<option value='"+$(this).val()+"'>"+$(this).html()+"</option>";

       $(this).remove();  

   });

    //Now appending the selected firs list's element to the list 1.

   $("#list1").append(backward_variable);

     //Sorting the list 2 so that it shows the list alphabetically

   sort_element("list1");

 }

 //Sorting function to sort the elements

 function sort_element(id)

 {

   var select_element = $('#'+id);

   var options_element = select_element.children('option').get();

   options_element.sort(function(a, b) {

     var compA = $(a).text().toUpperCase();

     var compB = $(b).text().toUpperCase();

     return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;

   })

   $.each(options_element, function(index, items) { select_element.append(items); });

 }

 </script>


Now comes the html portion.
 <select multiple="multiple" name="list1" id="list1" style="width:200px">

   <option value="1">Ecstasy</option>  

   <option value="2">Tanjim</option>

   <option value="3">Rex</option>

   <option value="4">Artisti</option>

   <option value="5">Infinity</option>

 </select>

 <input type="button" name="forward" id="forward" onclick="move_forward()" value=">>"/>

 <input type="button" name="backward" id="backward" onclick="move_backward()" value="<<"/>

 <select multiple="multiple" name="list2" id="list2" style="width:200px">

 </select>



Simple is not it? Copy and paste the code. Run..

Tuesday, October 16, 2012

ASP.NET Interview Questions - Part 1




1.       Normally the ASP.NET interviewer starts with.....

2.       What’ is the sequence in which ASP.NET events are processed?

3.       In which event are the controls fully loaded?

4.       How can we identify that the Page is Post Back?

5.       How does ASP.NET maintain state in between subsequent request?

6.       What is event bubbling?

7.       How do we assign page specific attributes?

8.       How do we ensure viewstate is not tampered?

9.       What is the use of @ Register directives?

10.   What is the use of Smart Navigation property?

11.   What is AppSetting Section in “Web.Config” file?

12.   Where is View State information stored?

13.   What is the use of @ Output Cache directive in ASP.NET?

14.   How can we create custom controls in ASP.NET?

15.   How many types of validation controls are provided by ASP.NET?

16.   Can you explain “AutoPostBack”?

17.   How can you enable automatic paging in Data Grid?

18.   What is the use of “GLOBAL.ASAX” file?

19.   What is the difference between “Web.config” and “Machine.Config”?

20.   What is a SESSION and APPLICATION object?

21.   What is the difference between ‘Server.Transfer’ and ‘response. Redirect’ ?

22.   What is the difference between Authentication and authorization?

23.   What is impersonation in ASP.NET?

24.   Can you explain in brief how the ASP.NET authentication process works?

25.   What are the various ways of authentication techniques in ASP.NET?

26.   How does authorization work in ASP.NET?

27.   What is difference between Data grid, Datalist, and repeater?

28.   From performance point of view, how do they rate?

29.   What is the method to customize columns in Data Grid?

30.   How can we format data inside Data Grid?

31.   How to decide on the design consideration to take a Data grid, data list, or repeater?