Guest User

Untitled

a guest
Aug 26th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. @Html.TextBoxFor for repeated properties in the model
  2. Public Class SampleData
  3. Public Property PTY_1 as String
  4. Public Property PTY_2 as String
  5. Public Property PTY_3 as String
  6. '...snipped
  7. Public Property PTY_19 as String
  8. Public Property PTY_20 as String
  9. End Class
  10.  
  11. <tr><td>@Html.TextBoxFor(Function(model) model.PTY_1)</td></tr>
  12. <tr><td>@Html.TextBoxFor(Function(model) model.PTY_2)</td></tr>
  13. <tr><td>@Html.TextBoxFor(Function(model) model.PTY_3)</td></tr>
  14. '...snipped
  15. <tr><td>@Html.TextBoxFor(Function(model) model.PTY_19)</td></tr>
  16. <tr><td>@Html.TextBoxFor(Function(model) model.PTY_20)</td></tr>
  17.  
  18. Public Class SampleData
  19. Public Property PTY(index as Integer) as String
  20. Get
  21. Select Case index
  22. Case 1 : Return PTY_1
  23. Case 2 : Return PTY_2
  24. Case 3 : Return PTY_3
  25. '...snipped
  26. Case 19 : Return PTY_19
  27. Case 20 : Return PTY_20
  28. Case Else : Return ""
  29. End Select
  30. End Get
  31. Set (value as String)
  32. Select case index
  33. Case 1 : PTY_1 = value
  34. Case 2 : PTY_2 = value
  35. Case 3 : PTY_3 = value
  36. '...snipped
  37. Case 19 : PTY_19 = value
  38. Case 20 : PTY_20 = value
  39. End Select
  40. End Set
  41. End Property
  42. End Class
  43.  
  44. @For index as Integer = 1 to 20
  45. <tr><td>@Html.TextBoxFor(Function(model) model.PTY(index))</td></tr>
  46. End For
  47.  
  48. @Html.EditorForModel()
  49.  
  50. <DataType(DataType.MultilineText)> _
  51. <UIHint("CustomTextArea")> _
  52. Public Property PTY_1 as String
  53.  
  54. ...
  55.  
  56. <tr><td>@Html.TextArea("")</td></tr>
  57.  
  58. @for (int i = 1; i <= 20; i++)
  59. {
  60. string name = "PTY_" + i;
  61. <tr><td><input type="text" name="@name" /></td></tr>
  62. }
Add Comment
Please, Sign In to add comment