1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <System.Runtime.CompilerServices.Extension()> _
Public Function ListOfFields(Helper As HtmlHelper, ListOfCustomFields As Dictionary(Of Integer,Fields),SelectListForCustomField As Dictionary(Of Integer,selectlist),optional GlobalClass As String="", _
optional GlobalStyle As String="",optional LabelClass As String="",optional LabelStyle As String="",optional FieldClass As String="",optional FieldStyle As String="") As IHtmlString
Dim ReturnString As String = ""
For Each Cntrl In ListOfCustomFields
ReturnString += String.Format("<div title='{0}' class='{1}' style='{2}'>", Cntrl.Value.Tooltip, GlobalClass, GlobalStyle)
Select Case Cntrl.Value.Type
Case "text"
Dim textbox As New TextBox
ReturnString += "<div class='" & LabelClass & "' style='" & labelStyle & "'>" & _
"<label for='ListOfCustomFields_" & Cntrl.Key & "_'>" & Cntrl.Value.Text & "</label>" & _
"</div>" & _
"<div class='" & FieldClass & "' style='" & FieldStyle & "' >" & _
"<input id='ListOfValuesOfCustomFields[" & Cntrl.Key & "]' name='ListOfValuesOfCustomFields[" & Cntrl.Key & "]' type='text' value=''/>" & _
"</div>"
Case "list"
ReturnString += "<div class='" & LabelClass & "' style='" & LabelStyle & "'>" & _
"<label for='ListOfCustomFields_" & Cntrl.Key & "_'>" & Cntrl.Value.Text & "</label>" & _
"</div>" & _
"<div class='" & FieldClass & "' style='" & FieldStyle & "'>" & _
"<select id='ListOfValuesOfCustomFields[" & Cntrl.Key & "]' name='ListOfValuesOfCustomFields[" & Cntrl.Key & "]'>"
For Each Element In (From e In SelectListForCustomField Where e.Key=Cntrl.Key Select e.Value).First
ReturnString += String.Format("<option {0} value='{1}'>{2}</option>", IIf(Element.Selected, "selected", ""), Element.Value, Element.Text)
Next
ReturnString += "</select>" & _
"</div>"
End Select
ReturnString += "</div>"
Next
Return New HtmlString(ReturnString)
End Function |
Partager