Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: v8 to v9 skin to master page

  1. #1
    mikemurphy is offline Senior Member
    Join Date
    Mar 2006
    Location
    United Kingdom
    Posts
    207

    Default v8 to v9 skin to master page

    ...So.....how to sort out forms within the master page......we have a search form in our old v8 skin, and not sure how to proceed to convert to v9 master pages
    ?????
    It would be a nested form within the master page form
    8.0.1.4 W2008R2 64-bit MSSQL2005

  2. #2
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    You pretty much don't. I wrote a library to help with the submission of forms to a server to aid my conversion. It uses JavaScript to trigger a post-back that can be used for anything.
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM

  3. #3
    danegus is offline Junior Member
    Join Date
    Sep 2008
    Posts
    15

    Default

    Are you Sharing?

  4. #4
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    I don't mind shareing, but I certainly wish that some of what I share would be put in main-line code and that others would share too.

    Code:
    //http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
    function post_to_url(path, params, method) {
        method = method || "post";
    
        var form = document.createElement("form");
    
        //move the submit function to another variable
        //so that it doesn't get over written
        form._submit_function_ = form.submit;
    
        form.setAttribute("method", method);
        form.setAttribute("action", path);
    
        for (var key in params) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", params[key]);
    
            form.appendChild(hiddenField);
        }
    
        document.body.appendChild(form);
        form._submit_function_(); //call the renamed function
    }
    
    function CollectFieldValues(container, prefix, hashtable) {
        var elems = document.getElementById(container).getElementsByTagName("*");
    
        for (var i = 0; i < elems.length; i++) {
            if (elems[i].id.indexOf(prefix) == 0) {
                hashtable[elems[i].name] = elems[i].value;
            }
        }
    }
    
    //http://stackoverflow.com/questions/929776/merging-associative-arrays-javascript
    Object.extend = function(destination, source) {
        for (var property in source)
            destination[property] = source[property];
        return destination;
    };
    
    function SendForm(container, prefix, subject, sendto, asxml, usexmlpackage, postto, method) {
        var hashtable = new Array();
    
        if (subject) {
            hashtable["Subject"] = subject;
        }
        if (sendto) {
            hashtable["SendTo"] = sendto;
        }
        if (asxml) {
            hashtable["AsXML"] = asxml;
        }
        if (usexmlpackage) {
            hashtable["UseXMLPackage"] = usexmlpackage;
        }
        postto = postto || "sendform.aspx";
    
        CollectFieldValues(container, prefix, hashtable);
    
        post_to_url(postto, hashtable, method);
    }
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM

  5. #5
    danegus is offline Junior Member
    Join Date
    Sep 2008
    Posts
    15

    Default

    Forgive my ignorance but how would i call my old/traditional form?

    like my current form submit line is :

    <form method="get" name="IQ_Form1" action="http://reservations.salvatores.net/V1WebControls/ResvMain.aspx">

    what would I do differently?

  6. #6
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    I added the javascript to the master page and set the SendForm.XmlPackage appConfig to be the name of the XML package. Then I set up a topic page with the following code. It is important to note that all you have to do is call SendForm with the proper parameters and the form will submit. By default the data will post to sendform.aspx and use the SendForm.XmlPackage package, however, you can specify any location to post to and any XmlPackage, which allows a great degree of flexibility when it comes to sending emails from templates.

    The syntax of SendForm is:

    SendForm([ID of the container the fields of the message are in], [the prefix of the fields with data to email], [optional: the subject of the email], [optional: the email address to send the message to], [optional: whether or not the message to send will be in XML format (always false if using this function, there for compatibility only)], [optional: the name of the xml package to use], [optional: the page to submit the values to], [optional: the method used to submit the values (post or get; post is default)]);

    The name value is paired with the value of the field when the data is send to the XmlPackage.

    Have a look at my code:

    Code:
    <strong>Please use the form below to request an account:</strong><br />
    <br />
    <div id="myForm">
    <div style="text-align: left; ">
    <table cellspacing="0" cellpadding="0" border="0" width="454">
        <tbody>
            <tr>
                <td valign="top" align="right" style="width: 102px; ">*Name:</td>
                <td valign="center" align="left" style="width: 348px; "><input gtbfieldid="59" id="input_AccountName" size="27" name="Name" /></td>
            </tr>
            <tr>
                <td valign="top" align="right" style="width: 102px; ">*Company:</td>
                <td valign="center" align="left" style="width: 348px; "><input gtbfieldid="62" id="input_AccountCompany" size="27" name="Company" /></td>
            </tr>
            <tr>
                <td valign="top" align="right" style="width: 102px; ">*Phone:</td>
                <td valign="center" align="left" style="width: 348px; "><input gtbfieldid="60" id="input_AccountPhone" size="27" name="Phone" /></td>
            </tr>
            <tr>
                <td valign="top" align="right" style="width: 102px; ">*E-Mail:</td>
                <td valign="center" align="left" style="width: 348px; "><input gtbfieldid="61" id="input_AccountEmail" size="27" name="EMail" /></td>
            </tr>
            <tr>
                <td valign="top" align="right" style="width: 102px; ">*ZIP:</td>
                <td valign="center" align="left" style="width: 348px; "><input gtbfieldid="61" id="input_AccountZIP" size="27" name="ZIP" /></td>
            </tr>
            <tr>
                <td style="width: 102px; "><br />
                </td>
                <td style="width: 348px; "><button type="button" onclick="SendForm('myForm','input_','New Wynparts User Request');">Submit</button></td>
            </tr>
        </tbody>
    </table>
    </div>
    </div>
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM

  7. #7
    McJoe is offline Member
    Join Date
    Oct 2007
    Posts
    50

    Default

    Taking the lazy approach and using some of the code above, this is my solution to use the existing asp.net form. Works well for cheap customers. I am using Jquery.

    <script type="text/javascript">
    //<![CDATA[
    function formpost() {
    $('#__VIEWSTATE').remove();
    theForm.setAttribute("action", 'sendform.aspx');
    theForm.submit();
    }
    //]]>
    </script>