Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a model object called wage with the following properties
C#
public class wage
{
  public string id {get;set;}
  public string name {get;set;}
  public IWageType type {get; private set;}

  public void SetType(int id)
  {
    if(type.Id!=id}
    { 
      if (id==1)
      type=new salary();
      else 
      type=new hourywage();
    }
  }
}

public interface IWageType 
{
 int id {get;}
}

The wage type can be either salary or hourly wage for example the salary class and the hourly wage classes are shown below
C#
public class salary:IwageType
{
 public int Id { get;}
 public double Amount {get;set;}
}

public class Hourlywage :IWageType
{
 public int Id {get;}
 public double Multiplier {get;set;}
 public double Rate {get;set;}
}

I am developing an asp .net mvc application using razor view engine.What I want is that when user selects the wage type from the dropdownlist if the for example the user selects "salary" from the dropdownlist the settype method in the wage should execute and the view should display the properties of the salary and if the user selects hourly wage from the dropdownlist the view should show the properties of the hourlywage.How can I accomplish this?I know the solution involves the use of jquery but I can not find resources to help me.Your help will be highly appreciated.
Posted
Updated 19-May-15 0:58am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900