Solved

Convert .net code to Classic ASP

Posted on 2015-01-14
4
260 Views
Last Modified: 2015-01-16
I know this might sound a little strange but I need to convert .net code to classic ASP so that we can use it in a classic ASP web application. I don't really know .net and I think it would take me a while to learn enough to do this myself. A lot of the code repeats itself so If I can get the 'translation' of one of the lines  of each block then I can do the rest myself obviously  :)

Maybe I should do this in parts, any advice is appreciated.

--------------

Imports System.EnterpriseServices
Imports System.Runtime.InteropServices
Imports QuikFormsEngine

Public Class clsQuickBridge

    Public Function CallQuik() As String

        Dim strHtml As String = ""
        Dim objQFE As QuikFormsEngine.QuikFormsEngine

        objQFE = New QuikFormsEngine.QuikFormsEngine

        'Enter the credentials for your Quik! account

        objQFE.QuikCustID = "customerid"
        objQFE.QuikUsername = "username"
        objQFE.QuikPassword = "password"

        'Configure settings to run the Quik! Forms Engine          
        objQFE.ErrorLogPath = "c:\TempOutput\"       'Set the location for the error log

        objQFE.OutputTempFiles = False          'If TRUE, writes output files to the computer's temporary directory.          
        objQFE.OutputPath = "c:\TempOutput\"     'If OutputTempFiles is TRUE, this value is ignored          
        objQFE.OutputFileName = "MyFileName"        'Set the name the output file (the file extension ".html" will be added automatically)

        'For test purposes...          
        objQFE.TestDataMode = False         'If TRUE, writes each field’s name as a default value into the field in order to validate that the form was built properly before publishing the form to PUBLISH status.          
        objQFE.TestFinalFormsMode = False   'If TRUE, sets the value indicating whether to view forms in final mode

        'Configure the form viewer window
        objQFE.HTMLTitle = "My Form Viewer Title" 'Sets the title of the HTML page
        objQFE.HTMLMetaNames = "<meta name=""viewport"" content=""width=device‐width, initial‐scale=1.0, user‐scalable=yes, minimumscale=1.0, maximum‐scale=1.0""/>" & _
                                "<meta name=""apple‐mobile‐web‐app‐capable"" content=""yes""/>" & _
                                "<meta name=""apple‐mobile‐web‐app‐status‐bar‐style"" content=""black""/>" 'Sets the meta names for theHTML page as a single string
        'objQFE.HTMLStyles = "" 'Sets the CSS styles for the page as a single string. Be careful about changing this value ‐ be sure toinclude the entire set of styles
        'objQFE.HTMLBodyOnloadFunction = "init()" 'Sets the “onload” function for the Body tag
        objQFE.HTMLLoadingImage = "https://www.quikforms.com/shared/images/quikformviewer/loading.gif"   'Sets the path to the loadingimage to display when the form is loading
        objQFE.HTMLLogoPath = "https://www.quikforms.com/shared/images/quikformviewer/logo.png"   'Sets the full URI path to the logofile ‐ 150px wide by 65px tall
        objQFE.HTMLLogoAltText = "Quik! Forms"  'Sets the logo image alternate text
        objQFE.HTMLMainInstruction = "Fill Out These Forms."   'Sets a custom main instruction on the form viewer
        objQFE.HTMLMinorInstruction = "Please fill out the forms below and click SUBMIT when you're done."   'Sets a custom minorinstruction on the form viewer

        objQFE.HTMLFieldFontColor = "#000000"   'Sets the font color for field data ‐ default is "Blue"
        objQFE.HTMLFooter = "Forms powered by Quik! ‐ <a href=""http://www.QuikForms.com"" target=""_blank"">www.QuikForms.com</a>"
        'Sets the value to display as the footer
        'objQFE.HTMLFooterStyle = ""    'Sets the HTML footer CSS or style in CSS format. Be careful about changing this value ‐ besure to include the entire set of styles

        '‐‐ Buttons ‐‐
        objQFE.HTMLShowButtonClear = True   'If true, shows the CLEAR button
        objQFE.HTMLShowButtonReset = True   'If true, shows the RESET button
        objQFE.HTMLShowButtonPrint = True   'If true, shows the PRINT button
        objQFE.HTMLShowButtonSave = True    'If true, shows the SAVE and LOAD buttonS
        objQFE.HTMLShowButtonSubmit = True  'If true, shows the SUBMIT button

        objQFE.SaveURL = "https://www.MyURL.com/SaveForm.html" 'The web page where you want the form to be saved to. NOTE: If set, thisoverrides the default save button functionality
        objQFE.SubmitURL = "https://www.MyURL.com/RecieveData.html" 'The web page where you want submitted data to be posted to

        'If you want to create your own javascript to control the submit action, then enter a custom javascript that will runwhen the Submit button is clicked. By default the submit action will POST the data to a URL, but you can override this functionality toperform validations, AJAX calls, etc.

        'objQFE.SubmitJavascript = "$.ajax({url:""https://websvcs.quikforms.com/HTMLFormViewTrans/v5202/FormViewHTML/QFVGetPDF.aspx?Edit=FALSE?"", type: 'POST', data: $('#QFVFormPage').serialize(),success : function(data) {  alert('Print routing succeeded: Form size: '+data.length + ' Bytes');}});"

        'objQFE.CustomJavaFileIncludePath = "https://www.MyURL.com/scripts/myCustomScript.js" 'Sets the customer’s custom javascriptfile path in an include statement within the <HEAD> tag. Only provide the URI, as the QFE will create the HTML tags automatically.
        'objQFE.CustomJavaScript = ""    'Sets the customer’s custom javascript text (function) in HTML format to append to the end ofthe HTML file. Entire script and proper tags must be included. Multiple scripts can be added as additional items, added to the list inorder of preference.
        'objQFE.jQueryFilePath = "https://www.quikforms.com/shared/scripts/QFE/jquery‐1.9.1.min.js" 'Sets the “src” attribute for thejQuery javascript file to use with the forms. Default version is 1.8.3 located in the “javascripts” folder where the HTML file issaved. (“javascripts/jquery‐1.9.1.min.js”)
        'objQFE.iScrollFilePath = "https://www.quikforms.com/shared/scripts/QFE/iscroll.js"  'Sets the “src” attribute for the iScrolljavascript file to use with the forms. Default version is 4.0 located in the “javascripts” folder where the HTML file is saved. (“javascripts/iscroll.js”)

        'Add the FormIDs to generate
        'NOTE: This would generally be done programmatically in a loop for all the forms selected by a user, not by setting explicithard‐coded values
        objQFE.AddFormID(39224)
        'objQFE.AddFormID(17)

        'Add data to prefill onto the form
        'NOTE: This would generally be done programmatically in a loop, not by setting explicit hard‐coded values
        objQFE.AddFieldToForm("1own.LName", "Smith")


        'objQFE.AddFieldToForm( _
        '  FieldName:="1own.H.Addr123", _
        '  FieldValue:="123 Main Street", _
        '  FieldReadOnly:=QuikFormsEngine.QFD.FieldReadOnly.NoRestrictions, _
        '  FieldVisibility:=QuikFormsEngine.QFD.FieldVisibility.None, _
        '  FieldRequired:=QuikFormsEngine.QFD.FieldRequired.NotRequired)

        'objQFE.AddFieldToForm( _
        '  FieldName:="1own.H.State", _
        '  FieldValue:="CA", _
        '  FieldReadOnly:=QuikFormsEngine.QFD.FieldReadOnly.NoRestrictions, _
        '  FieldVisibility:=QuikFormsEngine.QFD.FieldVisibility.None, _
        '  FieldRequired:=QuikFormsEngine.QFD.FieldRequired.NotRequired)

        'objQFE.AddFieldToForm( _
        '  FieldName:="1own.H.City", _
        '  FieldValue:="Los Angeles", _
        '  FieldReadOnly:=QuikFormsEngine.QFD.FieldReadOnly.NoRestrictions, _
        '  FieldVisibility:=QuikFormsEngine.QFD.FieldVisibility.None, _
        '  FieldRequired:=QuikFormsEngine.QFD.FieldRequired.NotRequired)

        'objQFE.AddFieldToForm( _
        '  FieldName:="1own.H.Zip", _
        '  FieldValue:="90007", _
        '  FieldReadOnly:=QuikFormsEngine.QFD.FieldReadOnly.NoRestrictions, _
        '  FieldVisibility:=QuikFormsEngine.QFD.FieldVisibility.None, _
        '  FieldRequired:=QuikFormsEngine.QFD.FieldRequired.NotRequired)

        'Sample settings
        objQFE.PreviewMode = False  'Set to TRUE to display form as preview only              
        objQFE.HostFormOnQuik = False   'Set to TRUE to return a URL to the HTML form instead of the raw HTML              
        objQFE.LogoURL = "http://www.quikforms.com"
        'objQFE.SetFieldPropertyByRole("1own", QuikFormsEngine.QFD.FieldReadOnly.Read_Only)
        'objQFE.SetFieldPropertyByFieldName("AcctNum", True) 'Mask the input like a password (shows * for each character entered)
        'objQFE.SetFieldPropertyByFieldName("SSN", "###‐##‐####")
        ''Force the value entered to be numeric and formatted (# = number, a = alpha)              
        'objQFE.SetFieldPropertyByFieldName("DOB", QuikFormsEngine.QFD.FieldReadOnly.Read_Only)
        'Set all date of birth fields to read‐only

        'Run the Quik! Forms Engine and return the HTML file name
        Dim arrFiles As ArrayList = Nothing
        arrFiles = objQFE.Execute

        'Check for errors in running the Quik! Forms Engine
        If objQFE.Results.ErrorFlag Then
            strHtml = "ErrorFlag = 1"
        Else
            'Redirect to the HTML file              
            'Dim objFile As QuikFormsEngine.QuikFormOutput              
            'For Each objFile In arrFiles              
            '    Dim strFileName As String = objFile.FullName              
            '    If strFileName = "" Then              
            '        strFileName = "ERROR! No forms were generated."              
            '        Response.Write(strFileName)              
            '    Else              
            '        Response.ContentType = "text/html"              
            '        Response.Redirect(strFileName)              
            '    End If              
            'Next

            'Write the HTML file out as a response


            Dim objFile As QuikFormsEngine.QuikFormOutput

            For Each objFile In arrFiles
                strHtml = objFile.HTMLData
                If strHtml = "" Then
                    strHtml = "ERROR! No forms were generated."
                End If
            Next

        End If

        Return strHtml

    End Function




End Class

-----
0
Comment
Question by:amucinobluedot
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
Shaun Kline earned 250 total points
Comment Utility
Instead of converting the code to classic ASP, I suggest doing one of two things:
1.) Create a web service that calls your .Net code, and from your classic ASP code, call the web service.
2.) Create a class library (DLL) in .Net with the appropriate entry points, and then use Server.CreateObject to create a reference in your classic ASP code, then call the desired entry points.

Both options would remove the need for conversion, and allow you to make changes to your .Net code without having to reconvert every time.
0
 
LVL 33

Assisted Solution

by:paulmacd
paulmacd earned 250 total points
Comment Utility
1) I've requested moderator intervention for reasons they will make clear to you.

2) Converting this from ASP.Net to classic ASP will almost certainly not be possible because the QuickForms product may or may not be reference-able from classic ASP.  Have you asked QuickForms about compatibility with classic ASP?

3) Is this code you own?  Or did this code come with the QuickForms product?
0
 

Author Comment

by:amucinobluedot
Comment Utility
We have that bridge to call the .net, we are trying to bypass that bridge by converting the code.
I will close the ticket and leave the bridge working as it is. thanks.
0
 

Author Closing Comment

by:amucinobluedot
Comment Utility
Thanks.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now