Public Function ConditionUIHTML(ByVal cond As Integer, ByVal sData As String) As String If sData Is Nothing Then sData = "" Dim s As New System.Text.StringBuilder ' ' All of the 'HTML related Condition procedures make use of a data string that HomeSeer stores ' and subsequently passes to these procedures. ConditionUIHTMLProc is where the HTML page ' that the user entered data into is returned as item=value pairs, which is what is used as ' the data string. ' Dim sTextBox As String = "Can you see me now?" Dim sText2 As String = "The OTHER Test" ' HomeSeer calls this procedure with a value of Cond starting at 1 and incrementing ' each time it is called until a null string ("") is returned. Each return that is ' not null is a new condition. When this procedure is called with a -1 value for ' the condition number, then that means the condition is being edited, and the ' sData parameter will contain the data string so that the HTML returned can include ' the existing values. If cond = -1 Then ' This is being called as part of an EDIT, so we ' need to show the existing data in the returned HTML. Dim p() As Pair = Nothing Dim paircount As Integer ' ' GetFormData converts a string in the form: name=value&name=value&name=value ' into pairs for easier processing. ' GetFormData(sData, paircount, p) If paircount < 1 Then Return "" For i As Integer = 0 To paircount - 1 If p(i).Name = "MyPlugTextBox" Then sTextBox = p(i).Value ElseIf p(i).Name.ToLower = "plug_cond_id" Then ' You can use any method you want for detecting which condition it is ' when there are multiple conditions. In this example, a hidden field ' is included in the HTML, which is then included in the saved data, ' that indicates which condition it is. Since the HTML is then built ' based upon the condition number in the select case below, we will ' set "cond" to the value that corresponds to the appropriate condition. ' If you do not use a select case statement to know which conditions to ' generate, you can adjust this to use your method to specify the condition. Select Case p(i).Value Case "Test Condition" cond = 1 Case "Another Condition" cond = 2 End Select End If Next End If ' ' Generate the HTML to be returned to HomeSeer and displayed. Note that if this condition ' is being edited, then the condition number passed to this procedure was -1, and the data ' string must contain some sort of indicator as to which condition is being edited. If that ' was done properly, then the cond parameter is changed to be the real condition number. ' ' IMPORTANT: ' You do NOT have unlimited boundaries on what HTML can be returned. You must understand that this ' HTML returned here will be a part of a table and inside a form already. Do not create any ' forms in this HTML unless you can process data entirely within the form using JavaScript as ' the contents of the form will not be returned! You may create tables, but make sure the tables ' are closed properly - do not leave any tables opened or include extra HTML tags or the ' output to the user will be corrupted and may prevent your conditions from working. ' Select Case cond Case 1 s.Append("Test HTML Condition" & vbTab) 'Always start with the condition name and vbTab (Chr(2)). s.Append("This is a test of the emergency broadcast network.
") s.Append(FormTextBox("Please enter something below:", "MyPlugTextBox", sTextBox, 30)) s.Append(HTML_NewLine) s.Append(FormCheckBox("Option A", "Opt_A", "A", True, False)) s.Append(HTML_StartFont(COLOR_RED)) s.Append(FormCheckBox("Option B", "Opt_B", "B", True, False)) s.Append(HTML_EndFont) s.Append(FormCheckBox("Option C", "Opt_A", "A", True, False)) ' Add my own indicator field so that I know which condition this is. s.Append(AddHidden("plug_cond_ID", "Test Condition")) Case 2 s.Append("Another Test Condition" & vbTab) 'Always start with the condition name and vbTab (Chr(2)). s.Append("HomeSeer ROCKS!
") s.Append(FormTextBox("", "2nd Condition Text", sText2, 50)) ' Add my own indicator field so that I know which condition this is. s.Append(AddHidden("plug_cond_ID", "Another Condition")) Case Else Return "" End Select Return s.ToString End Function