Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 2.03 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to create an else if statement in Razor?
  2. @model MvcApplication3.Models.ViewModels.New.Question.MatrixRows
  3.  
  4. @{
  5.     bool visible = Model.Visible;
  6. }
  7.  
  8. <tr>
  9.     <td>
  10.     @if(visible)
  11.         {
  12.         @Html.TextBoxFor(cn => Model.Row_Number, new { @class = "row required digits", size = 1 })
  13.         }
  14.     @if (!visible)
  15.         {
  16.         @Html.TextBoxFor(cn => Model.Row_Number, new { @class = "row required digits", size = 1, disabled = "disabled" })
  17.         }
  18.     </td>
  19.     <td>
  20.     @if(visible)
  21.         {
  22.             @Html.TextBoxFor(bs => Model.Row_Description, new { @class = "rowdesc", size = 45 })
  23.         }
  24.     @if (!visible)
  25.     {
  26.         @Html.TextBoxFor(bs => Model.Row_Description, new { @class = "rowdesc", size = 45, disabled = "disabled" })
  27.     }
  28.     </td>
  29.     <td>
  30.         @if (HttpContext.Current.User.IsInRole("Administrator"))
  31.         {
  32.             @Html.HiddenFor(x => x.Delete, new { @class = "mark-for-delete" })
  33.             @Html.LinkToRemoveNestedForm("Slet", "tr", "input.mark-for-delete")    
  34.         }
  35.         @if (HttpContext.Current.User.IsInRole("Moderator"))
  36.         {
  37.             @Html.HiddenFor(x => x.Visible, new { @class = "mark-for-visible" })
  38.             @Html.LinkToDisableNestedForm("Deaktiver", "tr", "input.mark-for-visible")    
  39.         }
  40.         @Html.HiddenFor(id => Model.Row_Id)
  41.     </td>
  42. </tr>
  43.        
  44. @{
  45.     ViewBag.Title = "Home Page";
  46. }
  47.        
  48. @if(visible)
  49. {
  50.     Html.TextBoxFor(bs => Model.Row_Description, new { @class = "rowdesc", size = 45 })
  51. }
  52. else
  53. {
  54.     Html.TextBoxFor(bs => Model.Row_Description, new { @class = "rowdesc", size = 45, disabled = "disabled" })
  55. }
  56.        
  57. @Html.TextBoxFor(bs => Model.Row_Description, new { @class = "rowdesc", size = 45, disabled = visible ? "" : "disabled" })
  58.        
  59. @if(visible)
  60.     {
  61.     @Html.TextBoxFor(cn => Model.Row_Number, new { @class = "row required digits", size = 1 })
  62.     }
  63. else
  64.     {
  65.     @Html.TextBoxFor(cn => Model.Row_Number, new { @class = "row required digits", size = 1, disabled = "disabled" })
  66.     }
  67.        
  68. @{
  69.     bool visible = Model.Visible;
  70.     ViewBag.Title = "My Title;
  71. }