ANBS controls

Set of functions to generate Bootstrap controls as strings. Controls available are Button, Inputbox, listbox and textarea along with or without label using Bootstrap 4.1 and Font-Awesome icons.
Can pass btn classes, and additional information, like if a button is for a modal, disabled, or regular, if a confirmation message is needed or not, if a control is read-only or not, also can pass width of grid for a label if label is needed.
ANBSListBox can accept either 1D ANStrArray, where item ID is same as Item name, or 2D ANStrArray where 1 for Item value and second for item name.
Functions are:
ANBSButton
ANBSInputBox
ANBSTextArea
ANBSListBox
:: Update 2018-06-30

Set2
Set3


Public

Tested

My Own Work
Function ANBSButton(URL_Or_ModalID_Or_Disabled, Caption, Classes, FAIcon, ConfirmMGS, DataParameters)
    ' If URL_Or_ModalID_Or_Disabled = some url, it will be active regular link
    '        If url is provided and ConfirmMGS is not blank, a confirm message will ask user before that link is executed
    ' If URL_Or_ModalID_Or_Disabled = "", disabled button
    ' If URL_Or_ModalID_Or_Disabled = "#modal", then it will be a modal link, needs to have a modalbox setup
    '         DataParameters must be like " data-1="rr" data-4="55"
    Diss                         = ""
    ConfDelete                = ""
    If URL_Or_ModalID_Or_Disabled = "" Or UCase(URL_Or_ModalID_Or_Disabled) = "D" Then Diss = " disabled=""disabled"" "
    If ConfirmMGS = 1 Then ConfDelete = " onclick=""return confirm('" & ConfirmMGS & "');"" "
    Rett                        = "    If Left(URL_Or_ModalID_Or_Disabled, 1) = "#" Then
        Rett                    = "
        Rett                    = Rett & "class=""btn " & Classes & """ " & DataParameters & " "
    End If
    ANBSButton                = Rett & ConfDelete & ">" & Caption & "
" & vbcrlf
End Function
Function ANBSInputBox(BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, BType)
    ' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
    ' Width of inputbox = 12 - LabelWidth (bootstrap grid width)
    ' BType = "password", "Text", ...
    ' Using Bootstrap 4, label width = 3, input box width = 9
    Rett                        = ""
    ReadOnly                    = ""
    Div2Close                = vbcrlf
    LabelWidth                = Fix(LabelWidth)
    If BType = "" Then BType = "text"
    If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
    If LabelWidth > 0 Then
        Rett                    = Rett & "
" & vbcrlf
        Rett                    = Rett & "" & vbcrlf
        Rett                    = Rett & "
" & vbcrlf
        Div2Close            = "
" & vbcrlf
    End If
    Rett                        = Rett & "    Rett                        = Rett & "placeholder=""" & RemoveHTML(BCaption) & """ class=""form-control"" "
    ANBSInputBox            = Rett & "value=""" & BValue & """ " & ReadOnly & " >" & Div2Close
End Function
Function ANBSTextArea(BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, RowsHeight)
    ' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
    ' Width of inputbox = 12 - LabelWidth (bootstrap grid width)
    ' RowsHeight is the height of textarea in rows
    Rett                        = ""
    ReadOnly                    = ""
    Div2Close                = vbcrlf
    LabelWidth                = Fix(LabelWidth)
    If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
    If fix(RowsHeight) < 1 Then RowsHeight    = 5
    If LabelWidth > 0 Then
        Rett                    = Rett & "
" & vbcrlf
        Rett                    = Rett & "" & vbcrlf
        Rett                    = Rett & "
" & vbcrlf
        Div2Close            = "
" & vbcrlf
    End If
    Rett                        = Rett & "" & Div2Close
End Function
Function ANBSListBox(BName, BList, BCaption, ReadOnly1_ReadWrite2, LabelWidth, InitialSelection, With1stSelection)
    ' BList is 2D list of ID and Value with SepaCol and SepaRow as separaters
    '    If BList is 1D (no SepaRow found), then items values will be same as items names
    ' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
    ' Width of Listbox = 12 - LabelWidth (bootstrap grid width)
    ' With1stSelection = 1 to have 1st item having [Please select] with value of 'No'
    ' InitialSelection can be either the ID of active item or the full text value
    ' Needs CutString, CutString3
    ' Needs SepaCol and SepaRow as separaters
    Rett                        = ""
    Div2Close                = vbcrlf
    LabelWidth                = Fix(LabelWidth)
    If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
    If LabelWidth > 0 Then
        Rett                    = Rett & "
" & vbcrlf
        Rett                    = Rett & "" & vbcrlf
        Rett                    = Rett & "
" & vbcrlf
        Div2Close            = "
" & vbcrlf
    End If
    Rett                        = Rett & "" & Div2Close
End Function

URL_Or_ModalID_Or_Disabled, Caption, Classes, FAIcon, ConfirmMGS, DataParameters
Or
BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, BType

Views 4924 Downloads 1379

Classic ASP UI
ANmarAmdeen
793
Attachments
Revisions

v6.0