Friday, July 20, 2012

How To call Mvc Function With Json



    $(document).ready(function () {
        $("#ddlModelSeries").change(function () {

            var Mname = $(this).val();

            $.getJSON("AddModelSeries/LoadBrand", { id: Mname }, function (AreaData) {
                var select = $("#ddlBrand"); select.empty(); select.append($('
                $.each(AreaData, function (index, itemData) {

                    select.append($('
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });

            });

        });


    });

             



how to hide menu in mvc 3 on master page





@if(Session["username"] !=null)
    {
 

 
     
 @Html.ActionLink("Manange Step", "Index", "Adminmanage")
 &nbsp 
@Html.ActionLink("Manange Errorcode", "Index", "Admin")&nbsp&nbsp

 @Html.ActionLink("LogOut", "LogOn", "Account")&nbsp&nbsp
     

        }

how pass value from page to javascript with hidden varible


@model UFixnow.Models.ModelSeries
@{
    ViewBag.Title = "Index";
   Layout = "~/Views/Shared/_Adminlayout.cshtml";
    var id = Session["SeriesId1"];
}





Tuesday, July 10, 2012

oops Concepts



 Abstraction

The process of picking out (abstracting) common features of objects and procedures. A programmer would use abstraction, for example, to note that two functions perform almost the same task and can be combined into a single function. Abstraction is one of the most important techniques in software engineering and is closely related to two other important techniques -- encapsulation and information hiding. All three techniques are used to reduce complexity.



Difference between Struct and Class

Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap.
Struct “do not support” inheritance, while class supports inheritance. However struct can implements interface.
Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.



Boxing and Un-Boxing

Boxing: means converting value-type to reference-type.

Eg:

int I = 20;

string s = I.ToSting();


UnBoxing: means converting reference-type to value-type.

Eg:

int I = 20;

string s = I.ToString(); //Box the int

int J = Convert.ToInt32(s); //UnBox it back to an int.


Note: Performance Overheads due to boxing and unboxing as the boxing makes a copy of value type from stack and place it inside an object of type System.Object in the heap.




http://dng-oops.blogspot.in/









Virtual Method

By declaring base class function as virtual, we allow the function to be overridden in any of derived class.

Eg:

Class parent

{

virtual void hello()

{ Console.WriteLine(“Hello from Parent”); }

}


Class child : parent

{

override void hello()

{ Console.WriteLine(“Hello from Child”); }

}


static void main()

{

parent objParent = new child();

objParent.hello();

}

//Output

Hello from Child.





Access Modifiers

Access Modifiers are keywords used to specify the declared accessibility of a member of a type.

Public is visible to everyone. A public member can be accessed using an instance of a class, by a class's internal code, and by any descendants of a class.


Private is hidden and usable only by the class itself. No code using a class instance can access a private member directly and neither can a descendant class.

Protected members are similar to private ones in that they are accessible only by the containing class. However, protected members also may be used by a descendant class. So members that are likely to be needed by a descendant class should be marked protected.




Encapsulation

Is the ability of an object to hide its data and methods from the rest of the world. It is one of the fundamental principles of OOPs.

Real time
e.g. / Ink is the important component in pen but it is hiding by some other material

Say we create a class, named Calculations. This class may contain a few members in the form of properties, events, fields or methods. Once the class is created, we may instantiate the class by creating an object out of it. The object acts as an instance of this class, the members of the class are not exposed to the outer world directly; rather, they are encapsulated by the class.

For example code

Public class Calculations
{
  private void fnMultiply(int x, int y)
  {
  return x * y;
  }
}
...
...
Calculations obj;
int Result;
Result = obj.fnMultiply(5,10)




ENCAPSULATION MEANS HIDING ALL THE INTERNAL DETAILS OF THE METHODS.

EXAMPLE cars and owners...
all the functions of cars are encapsulated with the owners..
No one else can access it...