Example 07 - Simple - Submit HTML form, and populate an Adobe LiveCycle form

Imports FDFApp
Partial Public Class example_07

    Inherits System.Web.UI.Page
    Private Debug_Me As Boolean = False
    Private Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
        Page.Validate()
        If (Page.IsValid) Then
            Example()
            Me.SubmitButton.Enabled = True
            Me.SubmitButton.CssClass = "button button-250 bgRed white"
        Else
            Update_Message("Message - Sent Failed!")
        End If
    End Sub
    Public Sub Example()
        ' DECLARE FDFApp & FDFDoc Classes
        Dim cFDFApp As New FDFApp.FDFApp_Class
        Dim cFDFDoc As New FDFApp.FDFDoc_Class
        ' INITIALIZE FDFDOC Class
        cFDFDoc = cFDFApp.FDFCreate
        ' SET FILE
        cFDFDoc.FDFSetFile(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1) & "example.pdf")
        ' SET FIELD VALUES
        cFDFDoc.FDFSetValue("FULLNAME", StripCodeFromString(Me.FULLNAME.Text & ""))
        cFDFDoc.FDFSetValue("EMAIL", StripCodeFromString(Me.EMAIL.Text & ""))
        cFDFDoc.FDFSetValue("COMBOBOX", StripCodeFromString(Me.COMBOBOX.SelectedValue.ToString() & ""))
        cFDFDoc.FDFSetValue("CHECKBOX", Me.CHECKBOX.Checked.ToString())
        cFDFDoc.FDFSetValue("LISTBOX", StripCodeFromString(Me.LISTBOX.SelectedValue.ToString() & ""))
        cFDFDoc.FDFSetValue("RADIOBUTTON", Me.frmRadiobutton0.Checked.ToString())

        Store_Cookie("Example_FULLNAME", StripCodeFromString(Me.FULLNAME.Text))
        Store_Cookie("Example_EMAIL", StripCodeFromString(Me.EMAIL.Text))
        'Store_Cookie("Example_COMBOBOX", StripCodeFromString(Me.COMBOBOX.SelectedValue))
        'Store_Cookie("Example_CHECKBOX", StripCodeFromString(Me.CHECKBOX.Checked.ToString()))
        'Store_Cookie("Example_LISTBOX", StripCodeFromString(Me.LISTBOX.SelectedValue))
        'Store_Cookie("Example_RADIOBUTTON", StripCodeFromString(Me.frmRadiobutton0.Checked.ToString()))

        ' SET FRAME
        cFDFDoc.FDFSetTargetFrame = "frame_examples"
        ' SET DOC JAVASCRIPT
        cFDFDoc.FDFSetOnImportJavaScript("var x = app.alert('Thank you for trying FDFToolkit.net!',3);", False)
        ' CLEAR THE OUTPUT STREAM
        Response.Clear()
        If Debug_Me Then
            Response.ContentType = cFDFApp.MimeTXT
        Else
            Response.ContentType = cFDFApp.MimePDF
        End If
        ' WRITE MERGED PDF FILE TO BUFFER
        Response.BinaryWrite(cFDFDoc.PDFMergeFDF2Buf(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1) & "example.pdf", False, ""))
        Response.End()
    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.SubmitButton.Text = "Submit"
        Me.SubmitButton.Enabled = True
        Me.SubmitButton.CssClass = "button button-250 bgRed white"
        Me.ResetButton.CssClass = "button button-250 bgRed white"
        Me.ResetButton.Text = "Reset"
        If Not IsPostBack Then
            Me.FULLNAME.Text = StripCodeFromString(Get_Cookie("Example_FULLNAME") & "")
            Me.EMAIL.Text = StripCodeFromString(Get_Cookie("Example_EMAIL") & "")
            'Me.COMBOBOX.SelectedValue = StripCodeFromString(Get_Cookie("Example_COMBOBOX") & "")
            'Me.CHECKBOX.Checked = StripCodeFromString(Get_Cookie("Example_CHECKBOX") & "")
            'Me.LISTBOX.SelectedValue = StripCodeFromString(Get_Cookie("Example_LISTBOX") & "")

            Me.SubmitButton.Enabled = True
            Me.SubmitButton.CssClass = "button button-250 bgRed white"
            FULLNAME.Focus()
        End If
        Update_Message("Complete this form, and then press submit.")
    End Sub
    Private Sub Update_Message(ByVal strMsg As String)
        Me.lblMessage_Top.Text = "Status: " & strMsg
        Me.lblMessage_Bottom.Text = "Status: " & strMsg
    End Sub

    Private Sub ResetButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ResetButton.Click
        Me.SubmitButton.Enabled = True
        Me.SubmitButton.CssClass = "button button-250 bgRed white"
    End Sub
End Class