Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding Combobox that's populated by Web Service
Message
 
To
07/07/2009 09:35:27
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01409942
Message ID:
01410528
Views:
31
Ok. I'm gonna give you all of it and didn't know if you wanted it embedded in the reply or if an alternative would be preferable. Here's the aspx, and the .cs follows:

newSale.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>WALA - New Sale</title>
    <link href="./App_Themes/MMTheme/mm.css" rel="stylesheet" type="text/css" />
    <link rel="Shortcut Icon" href="Images/favicon.ico" />

    <script type='text/javascript' src='./js/jquery.js'></script>

    <script type='text/javascript' src='./js/json2.js'></script>

    <script language="javascript" type="text/javascript">

        function getFees() {

            var iEventId = $("#cboEventName").val();
            if (iEventId != undefined) {
                $.ajax({
                    type: "POST",
                    url: "newSale.aspx/getFeesForEvent",
                    data: "{'eventId': '" + iEventId + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                        AjaxSucceeded(msg);
                    },
                    error: AjaxFailed
                });
            }
        }

        function AjaxSucceeded(result) {
            var cHTML = '';
            var oResults = JSON.parse(result.d);
            for (var i = 0; i < oResults.results.fees.length; i++) {
                cHTML += "<option value=\'" + oResults.results.fees[i].id + "\' title=\"'$" +  oResults.results.fees[i].fee + "'\" >" + oResults.results.fees[i].description + "</option>";
            }
            cFeeString = result.d;
            $("#cboFees").html(cHTML);
            showBalance();

        }

        function AjaxFailed(result) {
            alert(result.status + ' ' + result.statusText);
        }

        function showBalance() {
            var nFee = toFloat($("#cboFees :selected").attr("title"));
            var nPaid = toFloat($("#txtPayAmount").val());
            var nBalance = nFee - nPaid;
            $("#txtBalance").val(nBalance);
            if ($("#txtFee").val(nFee) == '') { $("#txtFee").val(nFee); }
            var iFeeId = $("#cboFees").val();
            $("#txtFeeId").val(iFeeId);
       }
        
        function toFloat(cFloat) {
            if (cFloat == '') {
                cFloat = '0';}
                           
            cFloat = cFloat.replace('$', '');
            cFloat = cFloat.replace(/'/g, '');
            var nFloat = parseFloat(cFloat);
            return nFloat;
        }

        var cFeeString = "";
        $(document).ready(function() {

        $("#cboEventName").change(getFees); // Ajax Function
        $("#cboFees").change(showBalance); // Ajax Function
        $("#txtPayAmount").change(showBalance);
        var currentTime = new Date();
        var cDate = currentTime.getMonth() + 1 + "/" +
        currentTime.getDate() + "/" + currentTime.getFullYear();

//            $("#txtRegDate_text").val(cDate);
//            $("#txtRegDate").val(cDate);
            getFees();  // Show the fees for the default event
            // alert("Hey Now!");
        });
           
    </script>

</head>
<body>
    <asp:ObjectDataSource ID="dsGolfEvents" runat="server" DataObjectTypeName="Wala.Membership.Business.EventGolfEntity"
        DeleteMethod="DeleteEntity" InsertMethod="CancelEntity" SelectMethod="GetAllEntities"
        TypeName="Wala.Membership.Business.EventGolf" UpdateMethod="SaveEntity"></asp:ObjectDataSource>
    <form id="frmNewPurchase" runat="server">
    <div>
        <table class="frmInfo">
            <tr>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblEventType" runat="server" AccessLevel="Full" BindingProperty="Text"
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
                        Text="What was purchased?"></mm:mmLabel>
                </td>
                <td>
                    <!-- If selling to individual, only 1st 3 choices needed-->
                    
                    <mm:mmDropDownList ID="lstEventType" runat="server" AccessLevel="Full" ControlID="00000000-0000-0000-0000-000000000000"
                        IsPostBack="False" SecuritySetup="True" Width="154px">
                        <asp:ListItem Selected="True" Value="2">Golf Event</asp:ListItem>
                        <asp:ListItem Value="1">Conference</asp:ListItem>
                        <asp:ListItem Value="3">Seminar</asp:ListItem>
                        <asp:ListItem Value="4">Web Ad</asp:ListItem>
                        <asp:ListItem Value="5">Newsletter</asp:ListItem>
                        <asp:ListItem Value="6">WETA</asp:ListItem>
                    </mm:mmDropDownList>
                </td>
            </tr>
            <tr>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblEventName" runat="server" AccessLevel="Full" BindingProperty="Text"
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
                        Text="Which Event?"></mm:mmLabel>
                </td>
                <td>
                    <mm:mmDropDownList ID="cboEventName" runat="server" AccessLevel="Full"
                        ControlID="00000000-0000-0000-0000-000000000000" DataSourceId="dsGolfEvents" 
                        DataTextField="txtName" DataValueField="numEvGolfID"  IsPostBack="False"
                        SecuritySetup="True" Width="350px" BindingSource="Reg_Golf"
                        BindingValueSource="Reg_Golf" BindingValueSourceMember="numEventID">
                    </mm:mmDropDownList>
                    <!-- BindingSource="Reg_Golf" 
                        BindingSourceDisplayMember="numEvGolfID" BindingSourceValueMember="txtName" -->
                </td>
            </tr>
            <tr>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblFees" runat="server" AccessLevel="Full" BindingProperty="Text"
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
                        Text="Fee Schedule:"></mm:mmLabel>
                </td>
                <td>
                <select name='cboFees' id='cboFees'>
                <!-- Filled in via ajax -->
                
                </select>
                <!--    <mm:mmDropDownList ID="cboFees" runat="server" AccessLevel="Full" BindingSource="Fee"
                        ControlID="00000000-0000-0000-0000-000000000000"
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="350px" 
                        BindingType="None">
                    </mm:mmDropDownList> -->
                    
                    <mm:mmTextBox ID="txtFeeId" runat="server" BindingSource="Reg_Golf" 
                        BindingSourceMember="numEvFeeId" Width="58px"></mm:mmTextBox>
                    
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblRegDate" runat="server" AccessLevel="Full" BindingProperty="Text"
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
                        Text="Registration Date:"></mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtRegDate" runat="server" Width="211px" 
                        BindingSource="Reg_Golf" BindingSourceMember="dtRegDate"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblHandicap" runat="server" AccessLevel="Full" BindingProperty="Text"
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
                        Text="Handicap:"></mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtHandicap" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="numGolfHandicap" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="29px"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblTeam" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Team # / Golfer #:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtTeam" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="numGolfTeamNumber" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="29px"></mm:mmTextBox>
                    <mm:mmTextBox ID="txtGolfer" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="txtGolfGolferNumber" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="29px"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblRaffle" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Raffle Prize:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtRaffle" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="txtGolfRafflePrize" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="350px"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblSponsor" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Sponsor Description:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtSponsor" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="txtGolfSponsorDescription" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="350px"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblSponsorAmt" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Sponsor Amt:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtSponsorAmt" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="curGolfSponsorAmt" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Class='currency'></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblComments" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Comments:" UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtComments" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="txtGolfComments" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="350px" 
                        Height="56px" TextMode="MultiLine"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblTeeHole" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Tee Off Hole:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtTeeHole" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="Tee_Off_On_Hole_Number" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="29px"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblSeller" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Seller:" UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtSeller" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="txtGolfSeller" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="350px"></mm:mmTextBox>
                </td>
            </tr>
            <tr class='golfEvent'>
                <td class="fieldNames">
                    Canceled?
                </td>
                <td>
                    <mm:mmCheckBox ID="chkCanceled" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="bCanceled" 
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False"
                        SecuritySetup="True" Text="" UserFieldName="" />
                </td>
            </tr>
            <!-- /* Payments */ -->
            <tr>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblFee" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Registration Fee:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtFee" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="curRegFee" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Class='currency'></mm:mmTextBox>
                </td>
            </tr>
            <tr>
                <td class="fieldNames">
                <!-- Payments already made -->
                 <mm:mmLabel ID="lblPayments" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Payments:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td  style='height:50px'>
                    <mm:mmListBox ID="lstPayments" runat="server" AccessLevel="Full" BindingSource=""
                        BindingSourceDisplayMember="" BindingSourceValueMember="" BindingValueSource=""
                        BindingValueSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Width="350px" Height="50px">
                    </mm:mmListBox>
                </td>
            </tr>
            <tr>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblPayAmount" runat="server" AccessLevel="Full" BindingProperty="Text"
                        ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
                        Text="Amount Paid:" Style="text-align:right;">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtPayAmount" runat="server" AccessLevel="Full" BindingSource="Reg_Golf"
                        BindingSourceMember="curRegPaid" 
                        ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" Class='currency'></mm:mmTextBox>
                </td>
            </tr>
            <tr>
                <td class="fieldNames">
                    <mm:mmLabel ID="lblBalance" runat="server" AccessLevel="Full" BindingProperty="Text"
                        BindingSource="" BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000"
                        DisplayFormat="" IsPostBack="False" SecuritySetup="True" Text="Balance Due:"
                        UserFieldName="">
                    </mm:mmLabel>
                </td>
                <td>
                    <mm:mmTextBox ID="txtBalance" runat="server" AccessLevel="Full" BindingSource=""
                        BindingSourceMember="" ControlID="00000000-0000-0000-0000-000000000000" DisplayFormat=""
                        IsPostBack="False" SecuritySetup="True" UserFieldName="" ReadOnly="True" Class="currency">
                    </mm:mmTextBox>
                </td>
            </tr>
            <tr>
            <td colspan='2' style='padding:10px; text-align:center;'>
        <mm:mmButton ID="btnSave" runat="server" AccessLevel="Full" BindingSource="" BindingSourceMember=""
            ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
            Text="Save Sale" UserFieldName="" onclick="btnSave_Click" />
        <mm:mmButton ID="btnStatement" runat="server" AccessLevel="Full" BindingSource="" BindingSourceMember=""
            ControlID="00000000-0000-0000-0000-000000000000" IsPostBack="False" SecuritySetup="True"
            Text="Print Statement" UserFieldName="" UseSubmitBehavior="False" />
                </td>
                <!-- <a href="#" class="jqmClose">Close</a> -->

            </tr>
        </table>
    </div>
    </form>
</body>
</html>
Previous
Reply
Map
View

Click here to load this message in the networking platform