Solved

Asp.net buttons not firing

Posted on 2012-04-02
10
556 Views
Last Modified: 2012-04-05
I added in a jquery api to validate addresses today and now that I have that working, the events that were being fired by buttons and dropdown changes aren't working.  For example, when the user clicks the btnManualUpload (line 410) the order should be inserted into the database but nothing appears to be happening.


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="OrderEntry_Staff.aspx.vb" Inherits="ProVal.OrderEntry_Staff" %>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="../Styles/Site.css" rel="stylesheet" type="text/css" /> 
    <title></title>
    <!-- jQuery -->
		<script type="text/javascript" src="https://api.qualifiedaddress.com/scripts/all-min.js"></script>

		<!-- jQuery UI -->
		<script type="text/javascript" src="https://api.qualifiedaddress.com/scripts/library.js"></script>

		<!-- jQuery Templates -->
		<script type="text/javascript" src="https://api.qualifiedaddress.com/scripts/qad.js"></script>
        <script language="javascript" type="text/javascript">
            QadApi
                (
                 {
                     timeout: 10,
                     key: xxxxxxxx,
                     busySubmit: false,
                     submitId: "btnVerify",
                     onComplete: function () { return false; }
                 },
                 {
                     busyId: "QadBusy",
                     busyText: "Validating address...",
                     animate: "slow",
                     addresses: 4
                 },
                 [
                  {
                      name: "Billing Address",
                      street: "txtAddress",
                      street2: "stxtAddress2",
                      unit: "id",
                      city: "txtCity",
                      state: "StateID",
                      zipcode: "txtZip",
                      plus4_code: "txtZipSuffix",
                      county: "txtCounty",
                      latitude: "txtLat",
                      longitude: "txtLong"

                  }
                 ]
                );
        </script>
        <script type="text/javascript">
            var url = 'https://api.qualifiedaddress.com/street-address/?street=1600+Amphitheatre+Parkway&city=Mountain+View&state=CA&zipcode=94043&candidates=5&auth-token=32497822';

            $.getJSON(url, function (data) {
                if (data.length > 0)
                    $('#shippingstreet').val(data[0].delivery_line1);
            });
        </script>
		    <!-- jQuery UI stylesheet -->
		    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" type="text/css" media="all" />
		    <style type="text/css">
			    .address-result {
				    cursor: pointer;
				    margin-bottom: 10px;
				    padding: 5px;
			    }
			    .address-result:hover {
				    background-color: gray;
			    }
			    .complete-address {
				    display: none;
			    }
			    .title {
				    color: gray;
				    font-size: smaller;
				    margin-bottom: 12px;
			    }
		        .style2
                {
                    width: 152px;
                }
		    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="wrap">
    <div id="header">
    <div class="logo">
   <h1>
       <img src="../Images/Logo.png" 
           alt="Transcontinental Valuations - Powered by ProVal" />
      <asp:Label ID="lblLogo" runat="server" Text="Transcontinental Valuations&#8482"></asp:Label>
      <br />
     <small class="slogan"><asp:Label ID="lblSmLogo" runat="server" Text="Powered by ProVal"></asp:Label>
      </small></h1> 
  </div>
  <div id="login">
           <asp:LoginView ID="LoginView1" runat="server">
        <AnonymousTemplate>
            You are not logged in.  Click the Login link to sign in.
                    <br />
                    </AnonymousTemplate>
        <LoggedInTemplate>
            Welcome,<asp:LoginName ID="LoginName1" runat="server" />
            <br />
            <asp:HyperLink ID="HyperLink1" runat="server"
                NavigateUrl="~/Users/ChangePassword.aspx" Font-Underline="True">Change Password</asp:HyperLink>
            <br />
        </LoggedInTemplate>
        </asp:LoginView>
        <asp:LoginStatus ID="LoginStatus2" runat="server" LogoutPageUrl="~/Default.aspx" 
                            ForeColor="#00009C" Font-Underline="True"  />
                
            <br />
                
            <asp:HyperLink ID="HyperLink4" runat="server" 
                NavigateUrl="../Users/RecoverPassword.aspx"  Font-Underline="True" 
                            ForeColor="#00009C">Forgot your password?</asp:HyperLink>
    </div>
    </div>
    
    <div class="clr"></div>
    <div id="nav">
    <ul>
    <li><asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="All.aspx">Open Orders</asp:HyperLink></li>
     <li><asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="Settings.aspx">Company Settings</asp:HyperLink></li>
     <li><asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="Accounting.aspx">Accounting</asp:HyperLink></li>
     <li><asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="OrderEntry_Staff.aspx">Order Entry</asp:HyperLink></li>
     </ul>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
        CssClass="ValidationError" DisplayMode="List" Width="906px" />
    <asp:Panel ID="pnlBulkOption" runat="server" Height="37px" 
        Width="899px">
        <asp:Button ID="btnBulkUpload" runat="server" Text="Upload an Excel Spreadsheet" 
            CausesValidation="False" Height="35px" Width="359px" />
            <asp:Label ID="lblSuccessfullyImport" runat="server" Font-Bold="True" Font-Size="Medium" Text="Order successfully imported"></asp:Label>
            </asp:Panel>
    
     <div>
     <asp:Panel ID="pnlManualOrder" runat="server" Visible="true" TabIndex="1" 
        Width="1123px">
   <h3>Order Details</h3>
    <table frame="void">
     <tr>
           <td><asp:Label ID="Label36" runat="server" Text="Loan #:*"></asp:Label></td>
           <td><asp:TextBox ID="txtLoanNumber" runat="server" TabIndex="1"></asp:TextBox></td>
           <td><asp:Label ID="Label4" runat="server" Text="Client Ref #:"></asp:Label></td>
           <td class="style2"><asp:TextBox ID="txtClientRefNum" runat="server" TabIndex="2"></asp:TextBox></td>
           <td><asp:Label ID="Label5" runat="server" Text="Case #:"></asp:Label></td>
           <td><asp:TextBox ID="txtCaseNumber" runat="server" TabIndex="3"></asp:TextBox></td>
           <td><asp:Label ID="Label6" runat="server" Text="Legal Desc :"></asp:Label></td>
           <td><asp:TextBox ID="txtLegalDesc" runat="server"  TabIndex="4"></asp:TextBox></td>
    </tr>
    <tr>
    <td><asp:Label ID="Label8" runat="server" Text="Location Type"></asp:Label>:</td>
    <td><asp:DropDownList ID="txtLocType" runat="server" AppendDataBoundItems="true" 
                    DataSourceID="LocationType" DataTextField="LocationTypeName" 
                    DataValueField="LocationTypeKey" TabIndex="5" CssClass="dropdown" >
                    <asp:ListItem Value="0"> (Select a Location)</asp:ListItem>
                    </asp:DropDownList></td>
    <td>
        <asp:Label ID="Label7" runat="server" Text="Property Type: *"></asp:Label>
        </td>
    <td class="style2">
        <asp:DropDownList ID="txtPropertyType" runat="server" 
            AppendDataBoundItems="True" CssClass="dropdown" DataSourceID="PropertyType" 
            DataTextField="PropertyTypeName" DataValueField="PropertyTypeKey" 
            TabIndex="6">
            <asp:ListItem Value="0">(Select a Property Type)</asp:ListItem>
        </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label17" runat="server" Text="Intended Use:"></asp:Label>
        </td>
    <td>
        <asp:DropDownList ID="IntendedUseID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="IntendedUse" DataTextField="IntendedUseName" 
            DataValueField="IntendedUseKey" TabIndex="7">
            <asp:ListItem Selected="True" Value="0"> (Select intended Use)</asp:ListItem>
        </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label35" runat="server" Text="Occupancy:"></asp:Label>
        </td>
    <td>
        <asp:DropDownList ID="OccupancyID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="Occupancy" DataTextField="OccupancyTypeName" 
            DataValueField="OccupancyTypeKey" TabIndex="8">
            <asp:ListItem Selected="True" Value="0"> (Select occupancy)</asp:ListItem>
        </asp:DropDownList>
        </td>
    </tr>
    <tr>
    <td>
        <asp:Label ID="Label33" runat="server" Text="Loan Amount:"></asp:Label>
        </td>
    <td>
        <asp:TextBox ID="intLoanAmount" runat="server" TabIndex="9"></asp:TextBox>
        
        </td>
    <td>
        <asp:Label ID="Label34" runat="server" Text="Loan Type:"></asp:Label>
        </td>
    <td class="style2">
        <asp:DropDownList ID="LoanTypeID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="LoanType" DataTextField="LoanTypeName" 
            DataValueField="LoanTypeKey" TabIndex="10">
            <asp:ListItem Selected="True" Value="0"> (Select loan type)</asp:ListItem>
        </asp:DropDownList>
        </td>
    </tr>
        <tr>
            <td>
                <asp:Label ID="Label9" runat="server" Text="Address: *"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtAddress" runat="server" TabIndex="11"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label10" runat="server" Text="Address 2:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="txtAddress2" runat="server" TabIndex="12"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label11" runat="server" Text="City:*"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtCity" runat="server" TabIndex="13"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label12" runat="server" Text="State:*"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="StateID" runat="server" AppendDataBoundItems="True" 
                    CausesValidation="True" CssClass="dropdown" DataSourceID="SqlDataSource1" 
                    DataTextField="StateName" DataValueField="StateAbbr" TabIndex="14">
                    <asp:ListItem Selected="True" Value="0"> (Select a State)</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label14" runat="server" Text="Zip: *"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtZip" runat="server" AutoPostBack="True" TabIndex="15" 
                    Width="68px"></asp:TextBox>
                &nbsp;-
                <asp:TextBox ID="txtZipSuffix" runat="server" AutoPostBack="True" Height="26px" 
                    TabIndex="15" Width="47px"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label13" runat="server" Text="County:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="txtCounty" runat="server" TabIndex="16"></asp:TextBox>
            </td>
            <td colspan="4">
             <asp:Button ID="Button1" runat="server" Text="Verify Address" CausesValidation="False" />
                <asp:TextBox ID="txtLat" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtLong" runat="server"></asp:TextBox>
            </td>
        </tr>
    <tr>
        <td>
            <asp:Label ID="Label41" runat="server" Text="Rush Type: *"></asp:Label>
        </td>
        <td>
            <asp:DropDownList ID="ddRushType" runat="server" AppendDataBoundItems="True" 
                CssClass="dropdown" DataSourceID="RushTypeList" DataTextField="RushType" 
                DataValueField="RushTypeKey" TabIndex="17">
                <asp:ListItem Selected="True" Value="3">None</asp:ListItem>
            </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label16" runat="server" Text="Client:*"></asp:Label>
        </td>
    <td class="style2">
        <asp:DropDownList ID="ClientID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="Client" DataTextField="ClientName" 
            DataValueField="ClientKey" TabIndex="18">
            <asp:ListItem Selected="True" Value="0"> (Select client)</asp:ListItem>
        </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label15" runat="server" Text="Report Type:*"></asp:Label>
        </td>
    <td>
        <asp:DropDownList ID="ReportTypeID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="ReportType" DataTextField="ReportTypeName" 
            DataValueField="ReportTypeKey" TabIndex="19" AutoPostBack="True">
            <asp:ListItem Selected="True" Value="0"> (Select a Report)</asp:ListItem>
        </asp:DropDownList>
        </td>
    </tr>
        <tr>
            <td>
                Client Due Date:</td>
            <td>
                <asp:TextBox ID="txtClientDueDate" runat="server" TabIndex="20"></asp:TextBox>
            </td>
            <td>
                Client Fee:&nbsp;
            </td>
            <td class="style2">
                <asp:TextBox ID="txtClientFee" runat="server" TabIndex="21"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    <h3>Borrower Details</h3>
    <table>
    <tr>
    <td><asp:Label ID="Label19" runat="server" Text="First Name"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrFirst" runat="server" TabIndex="22"></asp:TextBox></td>
    <td><asp:Label ID="Label20" runat="server" Text="Last Name :"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrLast" runat="server"  TabIndex="23"></asp:TextBox></td>
    <td><asp:Label ID="Label21" runat="server" Text="Home Phone:"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrHomeArea" runat="server"   TabIndex="24" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtBorrHomePrefix" runat="server" 
            Height="26px" TabIndex="25" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtBorrHomeSuffix" runat="server" Height="26px" TabIndex="26" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label22" runat="server" Text="Work Phone:"></asp:Label></td>
    <td>
        <asp:TextBox ID="txtBorrWorkArea" runat="server"   TabIndex="27" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtBorrWorkPrefix" runat="server" 
            Height="26px" TabIndex="28" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtBorrWorkSuffix" runat="server" Height="26px" TabIndex="29" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label23" runat="server" Text="Cell Phone:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtBorrCellArea" runat="server" Height="26px" MaxLength="3" 
                TabIndex="30" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtBorrCellPrefix" runat="server" Height="26px" MaxLength="3" 
                TabIndex="31" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;
            <asp:TextBox ID="txtBorrCellSuffix" runat="server" Height="26px" MaxLength="4" 
                TabIndex="32" Width="40px"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label24" runat="server" Text="Email"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrEmail" runat="server" TabIndex="33"></asp:TextBox></td>
    </tr>
    </table>
            
  <h3>Contact Details</h3>
    <table>
    <tr>
    <td><asp:Label ID="Label3" runat="server" Text="First Name"></asp:Label></td>
    <td><asp:TextBox ID="txtContFirst" runat="server" TabIndex="34"></asp:TextBox></td>
    <td class="style3"><asp:Label ID="Label18" runat="server" Text="Last Name :"></asp:Label></td>
    <td><asp:TextBox ID="txtContLast" runat="server"  TabIndex="35"></asp:TextBox></td>
    <td><asp:Label ID="Label37" runat="server" Text="Home Phone:"></asp:Label></td>
    <td><asp:TextBox ID="txtContHomeArea" runat="server"   TabIndex="36" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtContHomePrefix" runat="server" 
            Height="26px" TabIndex="37" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtContHomeSuffix" runat="server" Height="26px" TabIndex="38" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label25" runat="server" Text="Work Phone:"></asp:Label></td>
    <td>
        <asp:TextBox ID="txtContWorkArea" runat="server"   TabIndex="39" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtContWorkPrefix" runat="server" 
            Height="26px" TabIndex="40" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtContWorkSuffix" runat="server" Height="26px" TabIndex="41" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label26" runat="server" Text="Cell Phone:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtContCellArea" runat="server" Height="26px" MaxLength="3" 
                TabIndex="42" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtContCellPrefix" runat="server" Height="26px" MaxLength="3" 
                TabIndex="43" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtContCellSuffix" runat="server" Height="26px" MaxLength="4" 
                TabIndex="44" Width="40px"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label40" runat="server" Text="Email"></asp:Label></td>
    <td><asp:TextBox ID="txtContEmail" runat="server" TabIndex="45"></asp:TextBox></td>
    <td class="style3"> <asp:Label ID="Label32" runat="server" Text="Relation"></asp:Label></td>
    <td><asp:DropDownList ID="ContRelationID" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="Relation" DataTextField="RelationName" DataValueField="RelationKey" 
                                TabIndex="46"   CausesValidation="True" 
            CssClass="dropdown">
                                <asp:ListItem Selected="True" Value="0"> (Select relation)</asp:ListItem>
                            </asp:DropDownList></td>
    </tr>
    </table>
    </asp:Panel>
         <asp:Button ID="btnManualUpload" runat="server" Text="Submit"  />	  
		    

		    <div id="dialog">
			    <div id="candidates"></div>
		    </div>

		    <div id="results" style="display:none;"></div>

		    <script type="text/x-jquery-tmpl" id="address-candidate-template">
			    {{if user_input}}
			    <span class="title">You provided:</span><br />
			    {{else candidate_index === 0}}
			    <span class="title">We suggest:</span><br />
			    {{/if}}
			    <div class="address-result">
				    <span>${delivery_line_1}</span><br />
				    <span>${last_line}</span>
				    <span class="complete-address">${ JSON.stringify($item.data) }</span>
			    </div>
		    </script>
            <asp:Panel ID="pnlUpload" runat="server" Visible="false" Width="1019px">
                Please select an Excel file to import:<br /> <asp:FileUpload ID="FileUploadExcel" runat="server" style="margin-bottom: 0px" />
                <asp:Label ID="Label1" runat="server"></asp:Label><asp:Button ID="btnFileUpload" runat="server" Text="View Upload" />
                <asp:Button ID="btnWriteData" runat="server" Text="Write to File" />
                <br />
                <asp:Label ID="Label2" runat="server"></asp:Label></asp:Panel><asp:Panel ID="pnlImport" runat="server" Visible="false">
                </asp:Panel>
             <asp:SqlDataSource ID="LocationType" runat="server" 
                ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
                SelectCommand="SELECT DISTINCT [LocationTypeKey], [LocationTypeName] FROM [LocationType]">
            </asp:SqlDataSource>        
            <asp:SqlDataSource ID="ClientUsers" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="GetClientUsersByClientKey" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:FormParameter DefaultValue="" FormField="ClientID" Name="ClientKey" 
                        Type="Int32" />
                </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="RushTypeList" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="GetRushTypeList" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
                SelectCommand="SELECT [StateAbbr], [StateKey],[StateName] FROM [State] ORDER BY [StateAbbr]">
            </asp:SqlDataSource>
        <asp:SqlDataSource ID="PropertyType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT DISTINCT PropertyTypeKey, PropertyTypeName FROM PropertyType WHERE (Deleted IS NULL) ORDER BY PropertyTypeName">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="ReportType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [ReportTypeKey], [ReportTypeName] FROM [ReportType]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Client" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="GetClientList" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="IntendedUse" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [IntendedUseKey], [IntendedUseName], [Deleted] FROM [IntendedUse] ORDER BY [IntendedUseName]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Occupancy" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [OccupancyTypeKey], [OccupancyTypeName], [Deleted] FROM [OccupancyType] WHERE ([Deleted] IS NULL) ORDER BY [OccupancyTypeName]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="LoanType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [LoanTypeKey], [LoanTypeName] FROM [LoanType] WHERE ([Deleted] IS NULL) ORDER BY [LoanTypeName]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Relation" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [RelationKey], [RelationName] FROM [Relation] WHERE ([Deleted] IS NULL) ORDER BY [RelationName]">
        </asp:SqlDataSource>
       
        
   
    <asp:CompareValidator ID="vldPropType" runat="server" ControlToValidate="txtPropertyType" 
                                ErrorMessage="Property type required" Font-Bold="True" 
            Operator="NotEqual" ValueToCompare="0" Type="Integer" 
        CssClass="validError" Display="None"></asp:CompareValidator>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ErrorMessage="Loan # required, if none available please enter NA." 
        CssClass="validError" ControlToValidate="txtLoanNumber" Display="None"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="vldAddr" runat="server" 
                                ControlToValidate="txtAddress" ErrorMessage="Address is required" 
                                Font-Bold="True" Font-Size="XX-Small" 
        ForeColor="Red" Display="None"></asp:RequiredFieldValidator>
          
         <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ControlToValidate="txtCity" 
        ErrorMessage="City is required" Font-Bold="True" 
                                Font-Size="XX-Small" ForeColor="Red" 
        Display="None"></asp:RequiredFieldValidator>
  
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
        ErrorMessage="Zip code required" ControlToValidate="txtZip" 
        CssClass="validError" Display="None"></asp:RequiredFieldValidator>
                      <asp:RegularExpressionValidator ID="vld3BorrHmArea" 
        runat="server" ControlToValidate="txtBorrHomeArea" Display="None" 
        ErrorMessage="3 digits required in the Borrower home phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrHmPrefix" runat="server" 
        ControlToValidate="txtBorrHomePrefix" Display="None" 
        ErrorMessage="3 digits required in the borrower home phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld4BorrHmSuffix" runat="server" 
        ControlToValidate="txtBorrHomeSuffix" Display="None" 
        ErrorMessage="4 digits required in the borrower home phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
                      <br />
                    <asp:RegularExpressionValidator ID="vld5DigZip" runat="server" 
                                   
                                     ControlToValidate="txtZip" ErrorMessage="5 digit zip code required" 
                                     ValidationExpression="^\d{5}$" Display="None"></asp:RegularExpressionValidator>
   
                <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="ReportTypeID" 
                                ErrorMessage="Report type required" 
        Font-Bold="True" Operator="NotEqual" ValueToCompare="0" Type="Integer" 
        CssClass="validError" Display="None"></asp:CompareValidator>
                                 <asp:RegularExpressionValidator 
                ID="vldBorrEmail"
                runat="server" 
                ControlToValidate="txtBorrEmail"
                ErrorMessage="Proper email format required"
                ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
                CssClass="validError" Display="None"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator 
                ID="vldContEmail"
                runat="server" 
                ControlToValidate="txtContEmail"
                ErrorMessage="Proper email format required"
                ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
                CssClass="validError" Display="None"></asp:RegularExpressionValidator>
   
    <asp:CompareValidator ID="vldCompanyName" runat="server" 
        ControlToValidate="ClientID" Display="None" 
        ErrorMessage="Company name required" Operator="NotEqual" Type="Integer" 
        ValueToCompare="0"></asp:CompareValidator>
    <asp:RegularExpressionValidator ID="vld3BorrWkArea" runat="server" 
        ControlToValidate="txtBorrWorkArea" Display="None" 
        ErrorMessage="3 digits required in the Borrower work phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrWkPrefix" runat="server" 
        ControlToValidate="txtBorrWorkPrefix" Display="None" 
        ErrorMessage="3 digits required in the borrower work phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld4BorrWkSuffix" runat="server" 
        ControlToValidate="txtBorrWorkSuffix" Display="None" 
        ErrorMessage="4 digits required in the borrower work phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrCellArea" runat="server" 
        ControlToValidate="txtBorrCellArea" Display="None" 
        ErrorMessage="3 digits required in the Borrower cell phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrCellPrefix" runat="server" 
        ControlToValidate="txtBorrCellPrefix" 
        ErrorMessage="3 digits required in the borrower work phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrCell" runat="server" 
        ControlToValidate="txtBorrCellSuffix" Display="None" 
        ErrorMessage="4 digits required in the borrower cell phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContWorkArea" runat="server" 
        ControlToValidate="txtContWorkArea" Display="None" 
        ErrorMessage="3 digits required in the contact work phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContWorkPrefix" runat="server" 
        ControlToValidate="txtContWorkPrefix" Display="None" 
        ErrorMessage="3 digits required in the contact work phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld4ContWorkSuffix" runat="server" 
        ControlToValidate="txtContWorkSuffix" Display="None" 
        ErrorMessage="4 digits required in the contact work phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
    <asp:RequiredFieldValidator ID="vldClientFeeRequired" runat="server" 
        ControlToValidate="txtClientFee" Display="None" 
        ErrorMessage="The client fee is required"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="vldClientDueDateRequired" runat="server" 
        ControlToValidate="txtClientDueDate" Display="None" 
        ErrorMessage="Client due date required"></asp:RequiredFieldValidator>
    <br />
    <asp:RegularExpressionValidator ID="vld3ContHomeArea" runat="server" 
        ControlToValidate="txtContHomeArea" Display="None" ValidationExpression="^\d{3}$" 
        ErrorMessage="3 digits required in the contact home phone area code"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContHomePrefix" runat="server" 
        ControlToValidate="txtContHomePrefix" Display="None" ValidationExpression="^\d{3}$" 
        ErrorMessage="3 digits required in the contact home phone prefix"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContHomeSuffix" runat="server" 
        ControlToValidate="txtContHomeSuffix" Display="None" ValidationExpression="^\d{4}$" 
        ErrorMessage="4 digits required in the contact home phone suffix"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContCellArea" runat="server" 
        ControlToValidate="txtContCellArea" Display="None" ValidationExpression="^\d{3}$"
        ErrorMessage="3 digits required in the contact cell phone area code"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContCellPrefix" runat="server" 
        ControlToValidate="txtContCellPrefix" Display="None" ValidationExpression="^\d{3}$"
        ErrorMessage="3 digits required in the contact cell phone prefix"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContCellSuffix" runat="server" 
        ControlToValidate="txtContCellSuffix" Display="None" ValidationExpression="^\d{4}$"
        ErrorMessage="4 digits required in the contact cell phone suffix"></asp:RegularExpressionValidator>
       </div>
    <div id="main">
     </div> 
        <div id="footer">
      Copyright © 2012 
<br />Powered by ProVal
      </div>  
      </div>
      </div>
</form>
</body>
</html>

Open in new window



Public Class OrderEntry_Staff
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.Page.Request.IsAuthenticated Then
            Response.Redirect("~/Default.aspx")
        End If
        If Page.IsPostBack Then
            Dim wcICausedPostBack As WebControl = CType(GetControlThatCausedPostBack(TryCast(sender, Page)), WebControl)
            Dim indx As Integer = wcICausedPostBack.TabIndex
            Dim ctrl = _
             From control In wcICausedPostBack.Parent.Controls.OfType(Of WebControl)() _
             Where control.TabIndex > indx _
             Select control
            ctrl.DefaultIfEmpty(wcICausedPostBack).First().Focus()
        End If
        lblSuccessfullyImport.Visible = False
    End Sub

    Protected Sub btnBulkUpload_Click(sender As Object, e As EventArgs) Handles btnBulkUpload.Click
        pnlBulkOption.Visible = False
        'pnlManualOrder.Visible = False
        pnlUpload.Visible = True
        pnlImport.Visible = False
    End Sub
    Protected Sub btnFileUpload_Click(sender As Object, e As EventArgs) Handles btnFileUpload.Click

        If FileUploadExcel.HasFile Then
            Try
                Dim fileName As String = System.Guid.NewGuid.ToString + ".tmp"

                FileUploadExcel.SaveAs("C:\Windows\Temp\" & fileName)

                Label1.Text = "File name: " & FileUploadExcel.PostedFile.FileName & "<br>" & _
                             "Saved name: " & fileName & "<br />" & _
                              "File Size: " & FileUploadExcel.PostedFile.ContentLength & " kb<br>" & _
                           "Content type: " & FileUploadExcel.PostedFile.ContentType

                If FileUploadExcel.PostedFile.ContentLength < 100000 Then
                    Dim objReader As System.IO.StreamReader = New System.IO.StreamReader(FileUploadExcel.PostedFile.InputStream)
                    Dim data As String = objReader.ReadToEnd

                    Label2.Text = data
                Else
                    Label1.Text = "ERROR: The size of the file you uploaded is grater than 100kb."
                    Label2.Text = ""
                End If

            Catch ex As Exception
                Label1.Text = "ERROR: " & ex.Message.ToString()
                Label2.Text = ""
            End Try
        Else
            Label1.Text = "ERROR: You have not specified a file."
            Label2.Text = ""
        End If

    End Sub

    Protected Function ExcelConnection() As Odbc.OdbcCommand

        ' Connect to the Excel Spreadsheet
        Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Server.MapPath("ExcelImport.xls") & ";" & _
              "Extended Properties=Excel 8.0;"

        ' create your excel connection object using the connection string
        Dim objXConn As New Odbc.OdbcConnection(xConnStr)
        objXConn.Open()
        ' use a SQL Select command to retrieve the data from the Excel Spreadsheet
        ' the "table name" is the name of the worksheet within the spreadsheet
        ' in this case, the worksheet name is "Members" and is expressed as: [Members$]
        Dim objCommand As New Odbc.OdbcCommand("SELECT * FROM [tblImport$]", objXConn)
        Return objCommand
    End Function
    Private Sub ManualOrderUpload()
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.ManualOrder"

            cmd.Parameters.Add("@LoanNumber ", Data.SqlDbType.Char).Value = txtLoanNumber.Text
            cmd.Parameters.Add("@ClientRefNum ", Data.SqlDbType.Char).Value = txtClientRefNum.Text
            cmd.Parameters.Add("@CaseNumber ", Data.SqlDbType.Char).Value = txtCaseNumber.Text
            cmd.Parameters.Add("@LegalDesc ", Data.SqlDbType.Char).Value = txtLegalDesc.Text
            cmd.Parameters.Add("@LocTypeID ", Data.SqlDbType.Int).Value = IIf(txtLocType.SelectedValue = "0", DBNull.Value, Int32.Parse(txtLocType.SelectedItem.Value))
            cmd.Parameters.Add("@PropTypeID ", Data.SqlDbType.Int).Value = Int32.Parse(txtPropertyType.SelectedItem.Value)
            cmd.Parameters.Add("@Address ", Data.SqlDbType.Char).Value = txtAddress.Text
            cmd.Parameters.Add("@Address2 ", Data.SqlDbType.Char).Value = txtAddress2.Text
            cmd.Parameters.Add("@City ", Data.SqlDbType.Char).Value = txtCity.Text
            cmd.Parameters.Add("@StateID ", Data.SqlDbType.Char).Value = StateID.SelectedItem.Value
            cmd.Parameters.Add("@RushKey ", Data.SqlDbType.Char).Value = ddRushType.SelectedItem.Value
            cmd.Parameters.Add("@County ", Data.SqlDbType.Char).Value = txtCounty.Text
            cmd.Parameters.Add("@Zip ", Data.SqlDbType.Char).Value = txtZip.Text
            cmd.Parameters.Add("@ReportTypeID ", Data.SqlDbType.Int).Value = Int32.Parse(ReportTypeID.SelectedItem.Value)
            cmd.Parameters.Add("@ClientID ", Data.SqlDbType.Int).Value = Int32.Parse(ClientID.SelectedItem.Value)
            cmd.Parameters.Add("@IntendedUseID ", Data.SqlDbType.Int).Value = IIf(IntendedUseID.SelectedValue = "0", DBNull.Value, Int32.Parse(IntendedUseID.SelectedItem.Value))
            cmd.Parameters.Add("@OccupancyID ", Data.SqlDbType.Int).Value = IIf(OccupancyID.SelectedValue = "0", DBNull.Value, Int32.Parse(OccupancyID.SelectedItem.Value))
            cmd.Parameters.Add("@LoanTypeID ", Data.SqlDbType.Int).Value = IIf(LoanTypeID.SelectedValue = "0", DBNull.Value, Int32.Parse(LoanTypeID.SelectedItem.Value))
            cmd.Parameters.Add("@BorrFirst ", Data.SqlDbType.Char).Value = IIf(txtBorrFirst.Text = "", DBNull.Value, txtBorrFirst.Text)
            cmd.Parameters.Add("@BorrLast ", Data.SqlDbType.Char).Value = IIf(txtBorrLast.Text = "", DBNull.Value, txtBorrLast.Text)
            cmd.Parameters.Add("@BorrHomeArea", Data.SqlDbType.Char).Value = IIf(txtBorrHomeArea.Text = "", DBNull.Value, txtBorrHomeArea.Text)
            cmd.Parameters.Add("@BorrHomePrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrHomePrefix.Text = "", DBNull.Value, txtBorrHomePrefix.Text)
            cmd.Parameters.Add("@BorrHomeSuffix ", Data.SqlDbType.Char).Value = IIf(txtBorrHomeSuffix.Text = "", DBNull.Value, txtBorrHomeSuffix.Text)
            cmd.Parameters.Add("@BorrWorkArea", Data.SqlDbType.Char).Value = IIf(txtBorrWorkArea.Text = "", DBNull.Value, txtBorrWorkArea.Text)
            cmd.Parameters.Add("@BorrWorkPrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrWorkPrefix.Text = "", DBNull.Value, txtBorrWorkPrefix.Text)
            cmd.Parameters.Add("@BorrWorkSuffix ", Data.SqlDbType.Char).Value = IIf(txtBorrWorkSuffix.Text = "", DBNull.Value, txtBorrWorkSuffix.Text)
            cmd.Parameters.Add("@BorrCellArea", Data.SqlDbType.Char).Value = IIf(txtBorrCellArea.Text = "", DBNull.Value, txtBorrCellArea.Text)
            cmd.Parameters.Add("@BorrCellPrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrCellPrefix.Text = "", DBNull.Value, txtBorrCellPrefix.Text)
            cmd.Parameters.Add("@BorrCellSuffix ", Data.SqlDbType.Char).Value = IIf(txtBorrCellSuffix.Text = "", DBNull.Value, txtBorrCellSuffix.Text)
            cmd.Parameters.Add("@BorrEmail ", Data.SqlDbType.Char).Value = IIf(txtBorrEmail.Text = "", DBNull.Value, txtBorrEmail.Text)
            cmd.Parameters.Add("@ContHomeArea", Data.SqlDbType.Char).Value = IIf(txtContHomeArea.Text = "", DBNull.Value, txtContHomeArea.Text)
            cmd.Parameters.Add("@ContHomePrefix ", Data.SqlDbType.Char).Value = IIf(txtContHomePrefix.Text = "", DBNull.Value, txtContHomePrefix.Text)
            cmd.Parameters.Add("@ContHomeSuffix ", Data.SqlDbType.Char).Value = IIf(txtContHomeSuffix.Text = "", DBNull.Value, txtContHomeSuffix.Text)
            cmd.Parameters.Add("@ContWorkArea", Data.SqlDbType.Char).Value = IIf(txtContWorkArea.Text = "", DBNull.Value, txtContWorkArea.Text)
            cmd.Parameters.Add("@ContWorkPrefix ", Data.SqlDbType.Char).Value = IIf(txtContWorkPrefix.Text = "", DBNull.Value, txtContWorkPrefix.Text)
            cmd.Parameters.Add("@ContWorkSuffix ", Data.SqlDbType.Char).Value = IIf(txtContWorkSuffix.Text = "", DBNull.Value, txtContWorkSuffix.Text)
            cmd.Parameters.Add("@ContCellArea", Data.SqlDbType.Char).Value = IIf(txtContCellArea.Text = "", DBNull.Value, txtContCellArea.Text)
            cmd.Parameters.Add("@ContCellPrefix ", Data.SqlDbType.Char).Value = IIf(txtContCellPrefix.Text = "", DBNull.Value, txtContCellPrefix.Text)
            cmd.Parameters.Add("@ContCellSuffix ", Data.SqlDbType.Char).Value = IIf(txtContCellSuffix.Text = "", DBNull.Value, txtContCellSuffix.Text)
            cmd.Parameters.Add("@ContLast ", Data.SqlDbType.Char).Value = IIf(txtContLast.Text = "", DBNull.Value, txtContLast.Text)
            cmd.Parameters.Add("@ContFirst ", Data.SqlDbType.Char).Value = IIf(txtContFirst.Text = "", DBNull.Value, txtContFirst.Text)
            cmd.Parameters.Add("@ContEmail ", Data.SqlDbType.Char).Value = IIf(txtContEmail.Text = "", DBNull.Value, txtContEmail.Text)
            cmd.Parameters.Add("@ContRelationID ", Data.SqlDbType.Int).Value = IIf(ContRelationID.SelectedValue = "0", DBNull.Value, Int32.Parse(ContRelationID.SelectedItem.Value))
            cmd.Parameters.Add("@LoanAmount ", Data.SqlDbType.Decimal).Value = IIf(intLoanAmount.Text = "", DBNull.Value, intLoanAmount.Text)
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString

            cnn.Open()
            Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
        Finally
            cnn.Close()

            lblSuccessfullyImport.Visible = True
        End Try
    End Sub

    Protected Sub btnManualUpload_Click(sender As Object, e As EventArgs) Handles btnManualUpload.Click
        ManualOrderUpload()
    End Sub

    Protected Sub ReportTypeID_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ReportTypeID.SelectedIndexChanged
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.GetOrderClientDueDate"
            cmd.Parameters.Add("@ReportTypeKey", Data.SqlDbType.Int).Value = Int32.Parse(ReportTypeID.SelectedItem.Value)
            cmd.Parameters.Add("@RushTypeKey", Data.SqlDbType.Int).Value = ddRushType.SelectedItem.Value
            Dim dt As New System.Data.DataTable
            cnn.Open()
            Dim dr As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
            If dr.HasRows Then
                If Not IsDBNull(dr("ClientDueDate")) Then txtClientDueDate.Text = dr("ClientDueDate")
                If Not IsDBNull(dr("ClientFee")) Then txtClientFee.Text = dr("ClientFee")
            End If
        Finally
            cnn.Close()
        End Try
    End Sub

    Protected Function GetControlThatCausedPostBack(ByVal page As Page) As Control
        Dim control As Control = Nothing

        Dim ctrlname As String = page.Request.Params.Get("__EVENTTARGET")
        If ctrlname IsNot Nothing AndAlso ctrlname <> String.Empty Then
            control = page.FindControl(ctrlname)
        Else
            For Each ctl As String In page.Request.Form
                Dim c As Control = page.FindControl(ctl)
                If TypeOf c Is System.Web.UI.WebControls.Button OrElse TypeOf c Is System.Web.UI.WebControls.ImageButton Then
                    control = c
                    Exit For
                End If
            Next ctl
        End If
        Return control

    End Function
End Class

Open in new window

0
Comment
Question by:rcowen00
  • 5
  • 4
10 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 167 total points
ID: 37799827
Have you checked if the event is being caught eg. by breakpoint or showing a message ? (The problem might be elsewhere from what you think).
0
 
LVL 5

Accepted Solution

by:
Vishal Kedar earned 333 total points
ID: 37800224
Just add below bold portion line 410 in aspx code.

<asp:Button ID="btnManualUpload" OnClick="btnBulkUpload_Click"  runat="server" Text="Submit"  />
0
 

Author Comment

by:rcowen00
ID: 37801913
Ok, so when I click the button to insert a new order the validation runs as expected but I get the following error " Microsoft JScript runtime error: The value of the property 'ManualOrderUpload' is null or undefined, not a Function object"

I also get the following errors when I have an event triggered by a field change.  Same error for both events and they come from qad.js
0
 
LVL 5

Assisted Solution

by:Vishal Kedar
Vishal Kedar earned 333 total points
ID: 37802206
I think,There is an error in ManualOrderUpload function. This error can occur if you are trying to use an object which is null. In that code quite a lot of things can return null.
0
 

Author Comment

by:rcowen00
ID: 37802249
Will the line that I have here for a field that can be null, would this resolve the issue?  Thank you.

cmd.Parameters.Add("@BorrHomePrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrHomePrefix.Text = "", DBNull.Value, txtBorrHomePrefix.Text)
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 5

Expert Comment

by:Vishal Kedar
ID: 37804589
replace your code with below line


cmd.Parameters.Add("@BorrHomePrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrHomePrefix.Text == ""?DBNull.Value, txtBorrHomePrefix.Text)
0
 

Author Comment

by:rcowen00
ID: 37807554
vishal, I get an syntax error stating it Expects an Expression on the 2nd equal sign.
0
 
LVL 5

Expert Comment

by:Vishal Kedar
ID: 37809520
Please ignore above syntax, try below one

cmd.Parameters.Add("@BorrHomePrefix", System.Data.SqlDbType.Char).Value = txtBorrHomePrefix.Text == ""? DBNull.Value:txtBorrHomePrefix.Text;
0
 

Author Comment

by:rcowen00
ID: 37812869
Vishal,

I can't ignore the syntax because I can't build the project with the errors.  I have been doing some further research and found some issues.

1) The api that I put in place appears to trigger whenever the events that aren't firing should be.  I get 'Access Denied' (see item #2).

2) The api is reflecting a 'Access Denied' when running locally.  The api runs fine when published to the site.

3)  When I debug I get "Microsoft JScript runtime error: 'ManualOrderUpload' is undefined" and the following code is highlighted.  Is the bolded item causing my problem?  
<input type="submit" name="btnManualUpload" value="Submit" onclick="ManualOrderUpload();WebForm_DoPostBackWithOptions([b]new WebForm_PostBackOptions[/b](&quot;btnManualUpload&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="btnManualUpload" />	

Open in new window

0
 

Author Comment

by:rcowen00
ID: 37813042
Here is the final working code.  I'm not entirely sure what fixed it, but these are the items I changed:

- One button was not pointing to the correct action
- Added a Script Manager
- I did have a few fields that were not checking for nulls and could be null
 

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="OrderEntry_Staff.aspx.vb" Inherits="ProVal.OrderEntry_Staff" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="../Styles/Site.css" rel="stylesheet" type="text/css" /> 
    <title></title>
    <!-- jQuery -->
		<script type="text/javascript" src="https://api.qualifiedaddress.com/scripts/all-min.js" />

		<!-- jQuery UI -->
		<script type="text/javascript" src="https://api.qualifiedaddress.com/scripts/library.js" />

		<!-- jQuery Templates -->
		<script type="text/javascript" src="https://api.qualifiedaddress.com/scripts/qad.js" />
        <script language="javascript" type="text/javascript">
            QadApi
                (
                 {
                     timeout: 10,
                     key: 32497822,
                     busySubmit: false,
                     submitId: "btnVerify",
                     onComplete: function () { return false; }
                 },
                 {
                     busyId: "QadBusy",
                     busyText: "Validating address...",
                     animate: "slow",
                     addresses: 4
                 },
                 [
                  {
                      name: "Billing Address",
                      street: "txtAddress",
                      street2: "stxtAddress2",
                      unit: "id",
                      city: "txtCity",
                      state: "StateID",
                      zipcode: "txtZip",
                      plus4_code: "txtZipSuffix",
                      county: "txtCounty",
                      latitude: "txtLat",
                      longitude: "txtLong"

                  }
                 ]
                );
        </script>
        <script type="text/javascript">
            var url = 'https://api.qualifiedaddress.com/street-address/?street=1600+Amphitheatre+Parkway&city=Mountain+View&state=CA&zipcode=94043&candidates=5&auth-token=32497822';

            $.getJSON(url, function (data) {
                if (data.length > 0)
                    $('#shippingstreet').val(data[0].delivery_line1);
            });
        </script>
		    <!-- jQuery UI stylesheet -->
		    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" type="text/css" media="all" />
		    <style type="text/css">
			    .address-result {
				    cursor: pointer;
				    margin-bottom: 10px;
				    padding: 5px;
			    }
			    .address-result:hover {
				    background-color: gray;
			    }
			    .complete-address {
				    display: none;
			    }
			    .title {
				    color: gray;
				    font-size: smaller;
				    margin-bottom: 12px;
			    }
		        .style2
                {
                    width: 152px;
                }
		    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
    <div id="wrap">
    <div id="header">
    <div class="logo">
   <h1>
       <img src="../Images/Logo.png" 
           alt="Transcontinental Valuations - Powered by ProVal" />
      <asp:Label ID="lblLogo" runat="server" Text="Transcontinental Valuations&#8482"></asp:Label>
      <br />
     <small class="slogan"><asp:Label ID="lblSmLogo" runat="server" Text="Powered by ProVal"></asp:Label>
      </small></h1> 
  </div>
  <div id="login">
           <asp:LoginView ID="LoginView1" runat="server">
        <AnonymousTemplate>
            You are not logged in.  Click the Login link to sign in.
                    <br />
                    </AnonymousTemplate>
        <LoggedInTemplate>
            Welcome,<asp:LoginName ID="LoginName1" runat="server" />
            <br />
            <asp:HyperLink ID="HyperLink1" runat="server"
                NavigateUrl="~/Users/ChangePassword.aspx" Font-Underline="True">Change Password</asp:HyperLink>
            <br />
        </LoggedInTemplate>
        </asp:LoginView>
        <asp:LoginStatus ID="LoginStatus2" runat="server" LogoutPageUrl="~/Default.aspx" 
                            ForeColor="#00009C" Font-Underline="True"  />
                
            <br />
                
            <asp:HyperLink ID="HyperLink4" runat="server" 
                NavigateUrl="../Users/RecoverPassword.aspx"  Font-Underline="True" 
                            ForeColor="#00009C">Forgot your password?</asp:HyperLink>
    </div>
    </div>
    
    <div class="clr"></div>
    <div id="nav">
    <ul>
    <li><asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="All.aspx">Open Orders</asp:HyperLink></li>
     <li><asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="Settings.aspx">Company Settings</asp:HyperLink></li>
     <li><asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="Accounting.aspx">Accounting</asp:HyperLink></li>
     <li><asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="OrderEntry_Staff.aspx">Order Entry</asp:HyperLink></li>
     </ul>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
        CssClass="ValidationError" DisplayMode="List" Width="906px" />
    <asp:Panel ID="pnlBulkOption" runat="server" Height="37px" 
        Width="899px">
        <asp:Button ID="btnBulkUpload" runat="server" Text="Upload an Excel Spreadsheet" 
            CausesValidation="False" Height="35px" Width="359px" />
            <asp:Label ID="lblSuccessfullyImport" runat="server" Font-Bold="True" Font-Size="Medium" Text="Order successfully imported"></asp:Label>
            </asp:Panel>
    
     <div>
     <asp:Panel ID="pnlManualOrder" runat="server" Visible="true" TabIndex="1" 
        Width="1123px">
   <h3>Order Details</h3>
    <table frame="void">
     <tr>
           <td><asp:Label ID="Label36" runat="server" Text="Loan #:*"></asp:Label></td>
           <td><asp:TextBox ID="txtLoanNumber" runat="server" TabIndex="1"></asp:TextBox></td>
           <td><asp:Label ID="Label4" runat="server" Text="Client Ref #:"></asp:Label></td>
           <td class="style2"><asp:TextBox ID="txtClientRefNum" runat="server" TabIndex="2"></asp:TextBox></td>
           <td><asp:Label ID="Label5" runat="server" Text="Case #:"></asp:Label></td>
           <td><asp:TextBox ID="txtCaseNumber" runat="server" TabIndex="3"></asp:TextBox></td>
           <td><asp:Label ID="Label6" runat="server" Text="Legal Desc :"></asp:Label></td>
           <td><asp:TextBox ID="txtLegalDesc" runat="server"  TabIndex="4"></asp:TextBox></td>
    </tr>
    <tr>
    <td><asp:Label ID="Label8" runat="server" Text="Location Type"></asp:Label>:</td>
    <td><asp:DropDownList ID="txtLocType" runat="server" AppendDataBoundItems="true" 
                    DataSourceID="LocationType" DataTextField="LocationTypeName" 
                    DataValueField="LocationTypeKey" TabIndex="5" CssClass="dropdown" >
                    <asp:ListItem Value="0"> (Select a Location)</asp:ListItem>
                    </asp:DropDownList></td>
    <td>
        <asp:Label ID="Label7" runat="server" Text="Property Type: *"></asp:Label>
        </td>
    <td class="style2">
        <asp:DropDownList ID="txtPropertyType" runat="server" 
            AppendDataBoundItems="True" CssClass="dropdown" DataSourceID="PropertyType" 
            DataTextField="PropertyTypeName" DataValueField="PropertyTypeKey" 
            TabIndex="6">
            <asp:ListItem Value="0">(Select a Property Type)</asp:ListItem>
        </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label17" runat="server" Text="Intended Use:"></asp:Label>
        </td>
    <td>
        <asp:DropDownList ID="IntendedUseID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="IntendedUse" DataTextField="IntendedUseName" 
            DataValueField="IntendedUseKey" TabIndex="7">
            <asp:ListItem Selected="True" Value="0"> (Select intended Use)</asp:ListItem>
        </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label35" runat="server" Text="Occupancy:"></asp:Label>
        </td>
    <td>
        <asp:DropDownList ID="OccupancyID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="Occupancy" DataTextField="OccupancyTypeName" 
            DataValueField="OccupancyTypeKey" TabIndex="8">
            <asp:ListItem Selected="True" Value="0"> (Select occupancy)</asp:ListItem>
        </asp:DropDownList>
        </td>
    </tr>
    <tr>
    <td>
        <asp:Label ID="Label33" runat="server" Text="Loan Amount:"></asp:Label>
        </td>
    <td>
        <asp:TextBox ID="intLoanAmount" runat="server" TabIndex="9"></asp:TextBox>
        
        </td>
    <td>
        <asp:Label ID="Label34" runat="server" Text="Loan Type:"></asp:Label>
        </td>
    <td class="style2">
        <asp:DropDownList ID="LoanTypeID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="LoanType" DataTextField="LoanTypeName" 
            DataValueField="LoanTypeKey" TabIndex="10">
            <asp:ListItem Selected="True" Value="0"> (Select loan type)</asp:ListItem>
        </asp:DropDownList>
        </td>
    </tr>
        <tr>
            <td>
                <asp:Label ID="Label9" runat="server" Text="Address: *"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtAddress" runat="server" TabIndex="11"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label10" runat="server" Text="Address 2:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="txtAddress2" runat="server" TabIndex="12"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label11" runat="server" Text="City:*"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtCity" runat="server" TabIndex="13"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label12" runat="server" Text="State:*"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="StateID" runat="server" AppendDataBoundItems="True" 
                    CausesValidation="True" CssClass="dropdown" DataSourceID="SqlDataSource1" 
                    DataTextField="StateName" DataValueField="StateAbbr" TabIndex="14">
                    <asp:ListItem Selected="True" Value="0"> (Select a State)</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label14" runat="server" Text="Zip: *"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtZip" runat="server" AutoPostBack="True" TabIndex="15" 
                    Width="68px"></asp:TextBox>
                &nbsp;-
                <asp:TextBox ID="txtZipSuffix" runat="server" AutoPostBack="True" Height="26px" 
                    TabIndex="15" Width="47px"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="Label13" runat="server" Text="County:"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="txtCounty" runat="server" TabIndex="16"></asp:TextBox>
            </td>
            <td colspan="4">
             <asp:Button ID="Button1" runat="server" Text="Verify Address" CausesValidation="False" />
                <asp:TextBox ID="txtLat" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtLong" runat="server"></asp:TextBox>
            </td>
        </tr>
    <tr>
        <td>
            <asp:Label ID="Label41" runat="server" Text="Rush Type: *"></asp:Label>
        </td>
        <td>
            <asp:DropDownList ID="ddRushType" runat="server" AppendDataBoundItems="True" 
                CssClass="dropdown" DataSourceID="RushTypeList" DataTextField="RushType" 
                DataValueField="RushTypeKey" TabIndex="17">
                <asp:ListItem Selected="True" Value="3">None</asp:ListItem>
            </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label16" runat="server" Text="Client:*"></asp:Label>
        </td>
    <td class="style2">
        <asp:DropDownList ID="ClientKey" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="Client" DataTextField="ClientName" 
            DataValueField="ClientKey" TabIndex="18">
            <asp:ListItem Selected="True" Value="0"> (Select client)</asp:ListItem>
        </asp:DropDownList>
        </td>
    <td>
        <asp:Label ID="Label15" runat="server" Text="Report Type:*"></asp:Label>
        </td>
    <td>
        <asp:DropDownList ID="ReportTypeID" runat="server" AppendDataBoundItems="True" 
            CssClass="dropdown" DataSourceID="ReportType" DataTextField="ReportTypeName" 
            DataValueField="ReportTypeKey" TabIndex="19" AutoPostBack="True">
            <asp:ListItem Selected="True" Value="0"> (Select a Report)</asp:ListItem>
        </asp:DropDownList>
        </td>
    </tr>
        <tr>
            <td>
                Client Due Date:</td>
            <td>
                <asp:TextBox ID="txtClientDueDate" runat="server" TabIndex="20"></asp:TextBox>
            </td>
            <td>
                Client Fee:&nbsp;
            </td>
            <td class="style2">
                <asp:TextBox ID="txtClientFee" runat="server" TabIndex="21"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    <h3>Borrower Details</h3>
    <table>
    <tr>
    <td><asp:Label ID="Label19" runat="server" Text="First Name"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrFirst" runat="server" TabIndex="22"></asp:TextBox></td>
    <td><asp:Label ID="Label20" runat="server" Text="Last Name :"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrLast" runat="server"  TabIndex="23"></asp:TextBox></td>
    <td><asp:Label ID="Label21" runat="server" Text="Home Phone:"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrHomeArea" runat="server"   TabIndex="24" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtBorrHomePrefix" runat="server" 
            Height="26px" TabIndex="25" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtBorrHomeSuffix" runat="server" Height="26px" TabIndex="26" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label22" runat="server" Text="Work Phone:"></asp:Label></td>
    <td>
        <asp:TextBox ID="txtBorrWorkArea" runat="server"   TabIndex="27" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtBorrWorkPrefix" runat="server" 
            Height="26px" TabIndex="28" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtBorrWorkSuffix" runat="server" Height="26px" TabIndex="29" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label23" runat="server" Text="Cell Phone:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtBorrCellArea" runat="server" Height="26px" MaxLength="3" 
                TabIndex="30" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtBorrCellPrefix" runat="server" Height="26px" MaxLength="3" 
                TabIndex="31" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;
            <asp:TextBox ID="txtBorrCellSuffix" runat="server" Height="26px" MaxLength="4" 
                TabIndex="32" Width="40px"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label24" runat="server" Text="Email"></asp:Label></td>
    <td><asp:TextBox ID="txtBorrEmail" runat="server" TabIndex="33"></asp:TextBox></td>
    </tr>
    </table>
            
  <h3>Contact Details</h3>
    <table>
    <tr>
    <td><asp:Label ID="Label3" runat="server" Text="First Name"></asp:Label></td>
    <td><asp:TextBox ID="txtContFirst" runat="server" TabIndex="34"></asp:TextBox></td>
    <td class="style3"><asp:Label ID="Label18" runat="server" Text="Last Name :"></asp:Label></td>
    <td><asp:TextBox ID="txtContLast" runat="server"  TabIndex="35"></asp:TextBox></td>
    <td><asp:Label ID="Label37" runat="server" Text="Home Phone:"></asp:Label></td>
    <td><asp:TextBox ID="txtContHomeArea" runat="server"   TabIndex="36" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtContHomePrefix" runat="server" 
            Height="26px" TabIndex="37" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtContHomeSuffix" runat="server" Height="26px" TabIndex="38" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label25" runat="server" Text="Work Phone:"></asp:Label></td>
    <td>
        <asp:TextBox ID="txtContWorkArea" runat="server"   TabIndex="39" Height="26px" 
            Width="30px" MaxLength="3"></asp:TextBox>&nbsp;<asp:TextBox 
            ID="txtContWorkPrefix" runat="server" 
            Height="26px" TabIndex="40" Width="30px" MaxLength="3"></asp:TextBox>
        &nbsp;<asp:TextBox ID="txtContWorkSuffix" runat="server" Height="26px" TabIndex="41" 
            Width="40px" MaxLength="4"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label26" runat="server" Text="Cell Phone:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtContCellArea" runat="server" Height="26px" MaxLength="3" 
                TabIndex="42" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtContCellPrefix" runat="server" Height="26px" MaxLength="3" 
                TabIndex="43" Width="30px"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtContCellSuffix" runat="server" Height="26px" MaxLength="4" 
                TabIndex="44" Width="40px"></asp:TextBox>
        </td>
    <td><asp:Label ID="Label40" runat="server" Text="Email"></asp:Label></td>
    <td><asp:TextBox ID="txtContEmail" runat="server" TabIndex="45"></asp:TextBox></td>
    <td class="style3"> <asp:Label ID="Label32" runat="server" Text="Relation"></asp:Label></td>
    <td><asp:DropDownList ID="ContRelationID" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="Relation" DataTextField="RelationName" DataValueField="RelationKey" 
                                TabIndex="46"   CausesValidation="True" 
            CssClass="dropdown">
                                <asp:ListItem Selected="True" Value="0"> (Select relation)</asp:ListItem>
                            </asp:DropDownList></td>
    </tr>
    </table>
    </asp:Panel>
         <asp:Button ID="btnManualUpload" runat="server" OnClick="btnManualUpload_Click" Text="Submit" 
             onclientclick="ManualOrderUpload()" />	  
		    

		    <div id="dialog">
			    <div id="candidates"></div>
		    </div>

		    <div id="results" style="display:none;"></div>

		    <script type="text/x-jquery-tmpl" id="address-candidate-template">
			    {{if user_input}}
			    <span class="title">You provided:</span><br />
			    {{else candidate_index === 0}}
			    <span class="title">We suggest:</span><br />
			    {{/if}}
			    <div class="address-result">
				    <span>${delivery_line_1}</span><br />
				    <span>${last_line}</span>
				    <span class="complete-address">${ JSON.stringify($item.data) }</span>
			    </div>
		    </script>
            <asp:Panel ID="pnlUpload" runat="server" Visible="false" Width="1019px">
                Please select an Excel file to import:<br /> <asp:FileUpload ID="FileUploadExcel" runat="server" style="margin-bottom: 0px" />
                <asp:Label ID="Label1" runat="server"></asp:Label><asp:Button ID="btnFileUpload" runat="server" Text="View Upload" />
                <asp:Button ID="btnWriteData" runat="server" Text="Write to File" />
                <br />
                <asp:Label ID="Label2" runat="server"></asp:Label></asp:Panel><asp:Panel ID="pnlImport" runat="server" Visible="false">
                </asp:Panel>
             <asp:SqlDataSource ID="LocationType" runat="server" 
                ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
                SelectCommand="SELECT DISTINCT [LocationTypeKey], [LocationTypeName] FROM [LocationType]">
            </asp:SqlDataSource>        
            <asp:SqlDataSource ID="ClientUsers" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="GetClientUsersByClientKey" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:FormParameter DefaultValue="" FormField="ClientKey" Name="ClientKey" 
                        Type="Int32" />
                </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="RushTypeList" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="GetRushTypeList" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
                SelectCommand="SELECT [StateAbbr], [StateKey],[StateName] FROM [State] ORDER BY [StateAbbr]">
            </asp:SqlDataSource>
        <asp:SqlDataSource ID="PropertyType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT DISTINCT PropertyTypeKey, PropertyTypeName FROM PropertyType WHERE (Deleted IS NULL) ORDER BY PropertyTypeName">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="ReportType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [ReportTypeKey], [ReportTypeName] FROM [ReportType]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Client" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="GetClientList" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="IntendedUse" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [IntendedUseKey], [IntendedUseName], [Deleted] FROM [IntendedUse] ORDER BY [IntendedUseName]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Occupancy" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [OccupancyTypeKey], [OccupancyTypeName], [Deleted] FROM [OccupancyType] WHERE ([Deleted] IS NULL) ORDER BY [OccupancyTypeName]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="LoanType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [LoanTypeKey], [LoanTypeName] FROM [LoanType] WHERE ([Deleted] IS NULL) ORDER BY [LoanTypeName]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="Relation" runat="server" 
            ConnectionString="<%$ ConnectionStrings:myprovalConnectionString %>" 
            SelectCommand="SELECT [RelationKey], [RelationName] FROM [Relation] WHERE ([Deleted] IS NULL) ORDER BY [RelationName]">
        </asp:SqlDataSource>
       
        
   
    <asp:CompareValidator ID="vldPropType" runat="server" ControlToValidate="txtPropertyType" 
                                ErrorMessage="Property type required" Font-Bold="True" 
            Operator="NotEqual" ValueToCompare="0" Type="Integer" 
        CssClass="validError" Display="None"></asp:CompareValidator>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ErrorMessage="Loan # required, if none available please enter NA." 
        CssClass="validError" ControlToValidate="txtLoanNumber" Display="None"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="vldAddr" runat="server" 
                                ControlToValidate="txtAddress" ErrorMessage="Address is required" 
                                Font-Bold="True" Font-Size="XX-Small" 
        ForeColor="Red" Display="None"></asp:RequiredFieldValidator>
          
         <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ControlToValidate="txtCity" 
        ErrorMessage="City is required" Font-Bold="True" 
                                Font-Size="XX-Small" ForeColor="Red" 
        Display="None"></asp:RequiredFieldValidator>
  
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
        ErrorMessage="Zip code required" ControlToValidate="txtZip" 
        CssClass="validError" Display="None"></asp:RequiredFieldValidator>
                      <asp:RegularExpressionValidator ID="vld3BorrHmArea" 
        runat="server" ControlToValidate="txtBorrHomeArea" Display="None" 
        ErrorMessage="3 digits required in the Borrower home phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrHmPrefix" runat="server" 
        ControlToValidate="txtBorrHomePrefix" Display="None" 
        ErrorMessage="3 digits required in the borrower home phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld4BorrHmSuffix" runat="server" 
        ControlToValidate="txtBorrHomeSuffix" Display="None" 
        ErrorMessage="4 digits required in the borrower home phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
                      <br />
                    <asp:RegularExpressionValidator ID="vld5DigZip" runat="server" 
                                   
                                     ControlToValidate="txtZip" ErrorMessage="5 digit zip code required" 
                                     ValidationExpression="^\d{5}$" Display="None"></asp:RegularExpressionValidator>
   
                <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="ReportTypeID" 
                                ErrorMessage="Report type required" 
        Font-Bold="True" Operator="NotEqual" ValueToCompare="0" Type="Integer" 
        CssClass="validError" Display="None"></asp:CompareValidator>
                                 <asp:RegularExpressionValidator 
                ID="vldBorrEmail"
                runat="server" 
                ControlToValidate="txtBorrEmail"
                ErrorMessage="Proper email format required"
                ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
                CssClass="validError" Display="None"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator 
                ID="vldContEmail"
                runat="server" 
                ControlToValidate="txtContEmail"
                ErrorMessage="Proper email format required"
                ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
                CssClass="validError" Display="None"></asp:RegularExpressionValidator>
   
    <asp:CompareValidator ID="vldCompanyName" runat="server" 
        ControlToValidate="ClientKey" Display="None" 
        ErrorMessage="Company name required" Operator="NotEqual" Type="Integer" 
        ValueToCompare="0"></asp:CompareValidator>
    <asp:RegularExpressionValidator ID="vld3BorrWkArea" runat="server" 
        ControlToValidate="txtBorrWorkArea" Display="None" 
        ErrorMessage="3 digits required in the Borrower work phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrWkPrefix" runat="server" 
        ControlToValidate="txtBorrWorkPrefix" Display="None" 
        ErrorMessage="3 digits required in the borrower work phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld4BorrWkSuffix" runat="server" 
        ControlToValidate="txtBorrWorkSuffix" Display="None" 
        ErrorMessage="4 digits required in the borrower work phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrCellArea" runat="server" 
        ControlToValidate="txtBorrCellArea" Display="None" 
        ErrorMessage="3 digits required in the Borrower cell phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrCellPrefix" runat="server" 
        ControlToValidate="txtBorrCellPrefix" 
        ErrorMessage="3 digits required in the borrower work phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3BorrCell" runat="server" 
        ControlToValidate="txtBorrCellSuffix" Display="None" 
        ErrorMessage="4 digits required in the borrower cell phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContWorkArea" runat="server" 
        ControlToValidate="txtContWorkArea" Display="None" 
        ErrorMessage="3 digits required in the contact work phone area code" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContWorkPrefix" runat="server" 
        ControlToValidate="txtContWorkPrefix" Display="None" 
        ErrorMessage="3 digits required in the contact work phone prefix" 
        ValidationExpression="^\d{3}$"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld4ContWorkSuffix" runat="server" 
        ControlToValidate="txtContWorkSuffix" Display="None" 
        ErrorMessage="4 digits required in the contact work phone suffix" 
        ValidationExpression="^\d{4}$"></asp:RegularExpressionValidator>
    <asp:RequiredFieldValidator ID="vldClientFeeRequired" runat="server" 
        ControlToValidate="txtClientFee" Display="None" 
        ErrorMessage="The client fee is required"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="vldClientDueDateRequired" runat="server" 
        ControlToValidate="txtClientDueDate" Display="None" 
        ErrorMessage="Client due date required"></asp:RequiredFieldValidator>
    <br />
    <asp:RegularExpressionValidator ID="vld3ContHomeArea" runat="server" 
        ControlToValidate="txtContHomeArea" Display="None" ValidationExpression="^\d{3}$" 
        ErrorMessage="3 digits required in the contact home phone area code"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContHomePrefix" runat="server" 
        ControlToValidate="txtContHomePrefix" Display="None" ValidationExpression="^\d{3}$" 
        ErrorMessage="3 digits required in the contact home phone prefix"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContHomeSuffix" runat="server" 
        ControlToValidate="txtContHomeSuffix" Display="None" ValidationExpression="^\d{4}$" 
        ErrorMessage="4 digits required in the contact home phone suffix"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContCellArea" runat="server" 
        ControlToValidate="txtContCellArea" Display="None" ValidationExpression="^\d{3}$"
        ErrorMessage="3 digits required in the contact cell phone area code"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContCellPrefix" runat="server" 
        ControlToValidate="txtContCellPrefix" Display="None" ValidationExpression="^\d{3}$"
        ErrorMessage="3 digits required in the contact cell phone prefix"></asp:RegularExpressionValidator>
    <asp:RegularExpressionValidator ID="vld3ContCellSuffix" runat="server" 
        ControlToValidate="txtContCellSuffix" Display="None" ValidationExpression="^\d{4}$"
        ErrorMessage="4 digits required in the contact cell phone suffix"></asp:RegularExpressionValidator>
       </div>
    <div id="main">
     </div> 
        <div id="footer">
      Copyright © 2012 
<br />Powered by ProVal
      </div>  
      </div>
      </div>
</form>
</body>
</html>

Open in new window



Public Class OrderEntry_Staff
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.Page.Request.IsAuthenticated Then
            Response.Redirect("~/Default.aspx")
        End If
        If Page.IsPostBack Then
            Dim wcICausedPostBack As WebControl = CType(GetControlThatCausedPostBack(TryCast(sender, Page)), WebControl)
            Dim indx As Integer = wcICausedPostBack.TabIndex
            Dim ctrl = _
             From control In wcICausedPostBack.Parent.Controls.OfType(Of WebControl)() _
             Where control.TabIndex > indx _
             Select control
            ctrl.DefaultIfEmpty(wcICausedPostBack).First().Focus()
        End If
        lblSuccessfullyImport.Visible = False
    End Sub

    Protected Sub btnBulkUpload_Click(sender As Object, e As EventArgs) Handles btnBulkUpload.Click
        pnlBulkOption.Visible = False
        'pnlManualOrder.Visible = False
        pnlUpload.Visible = True
        pnlImport.Visible = False
    End Sub
    Protected Sub btnFileUpload_Click(sender As Object, e As EventArgs) Handles btnFileUpload.Click

        If FileUploadExcel.HasFile Then
            Try
                Dim fileName As String = System.Guid.NewGuid.ToString + ".tmp"

                FileUploadExcel.SaveAs("C:\Windows\Temp\" & fileName)

                Label1.Text = "File name: " & FileUploadExcel.PostedFile.FileName & "<br>" & _
                             "Saved name: " & fileName & "<br />" & _
                              "File Size: " & FileUploadExcel.PostedFile.ContentLength & " kb<br>" & _
                           "Content type: " & FileUploadExcel.PostedFile.ContentType

                If FileUploadExcel.PostedFile.ContentLength < 100000 Then
                    Dim objReader As System.IO.StreamReader = New System.IO.StreamReader(FileUploadExcel.PostedFile.InputStream)
                    Dim data As String = objReader.ReadToEnd

                    Label2.Text = data
                Else
                    Label1.Text = "ERROR: The size of the file you uploaded is grater than 100kb."
                    Label2.Text = ""
                End If

            Catch ex As Exception
                Label1.Text = "ERROR: " & ex.Message.ToString()
                Label2.Text = ""
            End Try
        Else
            Label1.Text = "ERROR: You have not specified a file."
            Label2.Text = ""
        End If

    End Sub

    Protected Function ExcelConnection() As Odbc.OdbcCommand

        ' Connect to the Excel Spreadsheet
        Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Server.MapPath("ExcelImport.xls") & ";" & _
              "Extended Properties=Excel 8.0;"

        ' create your excel connection object using the connection string
        Dim objXConn As New Odbc.OdbcConnection(xConnStr)
        objXConn.Open()
        ' use a SQL Select command to retrieve the data from the Excel Spreadsheet
        ' the "table name" is the name of the worksheet within the spreadsheet
        ' in this case, the worksheet name is "Members" and is expressed as: [Members$]
        Dim objCommand As New Odbc.OdbcCommand("SELECT * FROM [tblImport$]", objXConn)
        Return objCommand
    End Function
    Private Sub ManualOrderUpload()
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.ManualOrder"

            cmd.Parameters.Add("@LoanNumber ", Data.SqlDbType.Char).Value = txtLoanNumber.Text
            cmd.Parameters.Add("@ClientRefNum ", Data.SqlDbType.Char).Value = IIf(txtClientRefNum.Text = "", DBNull.Value, txtClientRefNum.Text)
            cmd.Parameters.Add("@CaseNumber ", Data.SqlDbType.Char).Value = IIf(txtCaseNumber.Text = "", DBNull.Value, txtCaseNumber.Text)
            cmd.Parameters.Add("@LegalDesc ", Data.SqlDbType.Char).Value = IIf(txtLegalDesc.Text = "", DBNull.Value, txtLegalDesc.Text)
            cmd.Parameters.Add("@LocTypeID ", Data.SqlDbType.Int).Value = IIf(txtLocType.SelectedValue = "0", DBNull.Value, Int32.Parse(txtLocType.SelectedItem.Value))
            cmd.Parameters.Add("@PropTypeID ", Data.SqlDbType.Int).Value = IIf(txtPropertyType.SelectedItem.Value = "0", DBNull.Value, Int32.Parse(txtPropertyType.SelectedItem.Value))
            cmd.Parameters.Add("@Address ", Data.SqlDbType.Char).Value = txtAddress.Text
            cmd.Parameters.Add("@Address2 ", Data.SqlDbType.Char).Value = IIf(txtAddress2.Text = "", DBNull.Value, txtAddress2.Text)
            cmd.Parameters.Add("@City ", Data.SqlDbType.Char).Value = txtCity.Text
            cmd.Parameters.Add("@StateID ", Data.SqlDbType.Char).Value = StateID.SelectedItem.Value
            cmd.Parameters.Add("@RushKey ", Data.SqlDbType.Char).Value = ddRushType.SelectedItem.Value
            cmd.Parameters.Add("@County ", Data.SqlDbType.Char).Value = IIf(txtCounty.Text = "", DBNull.Value, txtCounty.Text)
            cmd.Parameters.Add("@Zip ", Data.SqlDbType.Char).Value = txtZip.Text
            cmd.Parameters.Add("@ZipSuffix ", Data.SqlDbType.Char).Value = IIf(txtZipSuffix.Text = "", DBNull.Value, txtZipSuffix.Text)
            cmd.Parameters.Add("@ReportTypeID ", Data.SqlDbType.Int).Value = Int32.Parse(ReportTypeID.SelectedItem.Value)
            cmd.Parameters.Add("@ClientID ", Data.SqlDbType.Int).Value = Int32.Parse(ClientKey.SelectedItem.Value)
            cmd.Parameters.Add("@IntendedUseID ", Data.SqlDbType.Int).Value = IIf(IntendedUseID.SelectedValue = "0", DBNull.Value, Int32.Parse(IntendedUseID.SelectedItem.Value))
            cmd.Parameters.Add("@OccupancyID ", Data.SqlDbType.Int).Value = IIf(OccupancyID.SelectedValue = "0", DBNull.Value, Int32.Parse(OccupancyID.SelectedItem.Value))
            cmd.Parameters.Add("@LoanTypeID ", Data.SqlDbType.Int).Value = IIf(LoanTypeID.SelectedValue = "0", DBNull.Value, Int32.Parse(LoanTypeID.SelectedItem.Value))
            cmd.Parameters.Add("@BorrFirst ", Data.SqlDbType.Char).Value = IIf(txtBorrFirst.Text = "", DBNull.Value, txtBorrFirst.Text)
            cmd.Parameters.Add("@BorrLast ", Data.SqlDbType.Char).Value = IIf(txtBorrLast.Text = "", DBNull.Value, txtBorrLast.Text)
            cmd.Parameters.Add("@BorrHomeArea", Data.SqlDbType.Char).Value = IIf(txtBorrHomeArea.Text = "", DBNull.Value, txtBorrHomeArea.Text)
            cmd.Parameters.Add("@BorrHomePrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrHomePrefix.Text = "", DBNull.Value, txtBorrHomePrefix.Text)
            cmd.Parameters.Add("@BorrHomeSuffix ", Data.SqlDbType.Char).Value = IIf(txtBorrHomeSuffix.Text = "", DBNull.Value, txtBorrHomeSuffix.Text)
            cmd.Parameters.Add("@BorrWorkArea", Data.SqlDbType.Char).Value = IIf(txtBorrWorkArea.Text = "", DBNull.Value, txtBorrWorkArea.Text)
            cmd.Parameters.Add("@BorrWorkPrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrWorkPrefix.Text = "", DBNull.Value, txtBorrWorkPrefix.Text)
            cmd.Parameters.Add("@BorrWorkSuffix ", Data.SqlDbType.Char).Value = IIf(txtBorrWorkSuffix.Text = "", DBNull.Value, txtBorrWorkSuffix.Text)
            cmd.Parameters.Add("@BorrCellArea", Data.SqlDbType.Char).Value = IIf(txtBorrCellArea.Text = "", DBNull.Value, txtBorrCellArea.Text)
            cmd.Parameters.Add("@BorrCellPrefix ", Data.SqlDbType.Char).Value = IIf(txtBorrCellPrefix.Text = "", DBNull.Value, txtBorrCellPrefix.Text)
            cmd.Parameters.Add("@BorrCellSuffix ", Data.SqlDbType.Char).Value = IIf(txtBorrCellSuffix.Text = "", DBNull.Value, txtBorrCellSuffix.Text)
            cmd.Parameters.Add("@BorrEmail ", Data.SqlDbType.Char).Value = IIf(txtBorrEmail.Text = "", DBNull.Value, txtBorrEmail.Text)
            cmd.Parameters.Add("@ContHomeArea", Data.SqlDbType.Char).Value = IIf(txtContHomeArea.Text = "", DBNull.Value, txtContHomeArea.Text)
            cmd.Parameters.Add("@ContHomePrefix ", Data.SqlDbType.Char).Value = IIf(txtContHomePrefix.Text = "", DBNull.Value, txtContHomePrefix.Text)
            cmd.Parameters.Add("@ContHomeSuffix ", Data.SqlDbType.Char).Value = IIf(txtContHomeSuffix.Text = "", DBNull.Value, txtContHomeSuffix.Text)
            cmd.Parameters.Add("@ContWorkArea", Data.SqlDbType.Char).Value = IIf(txtContWorkArea.Text = "", DBNull.Value, txtContWorkArea.Text)
            cmd.Parameters.Add("@ContWorkPrefix ", Data.SqlDbType.Char).Value = IIf(txtContWorkPrefix.Text = "", DBNull.Value, txtContWorkPrefix.Text)
            cmd.Parameters.Add("@ContWorkSuffix ", Data.SqlDbType.Char).Value = IIf(txtContWorkSuffix.Text = "", DBNull.Value, txtContWorkSuffix.Text)
            cmd.Parameters.Add("@ContCellArea", Data.SqlDbType.Char).Value = IIf(txtContCellArea.Text = "", DBNull.Value, txtContCellArea.Text)
            cmd.Parameters.Add("@ContCellPrefix ", Data.SqlDbType.Char).Value = IIf(txtContCellPrefix.Text = "", DBNull.Value, txtContCellPrefix.Text)
            cmd.Parameters.Add("@ContCellSuffix ", Data.SqlDbType.Char).Value = IIf(txtContCellSuffix.Text = "", DBNull.Value, txtContCellSuffix.Text)
            cmd.Parameters.Add("@ContLast ", Data.SqlDbType.Char).Value = IIf(txtContLast.Text = "", DBNull.Value, txtContLast.Text)
            cmd.Parameters.Add("@ContFirst ", Data.SqlDbType.Char).Value = IIf(txtContFirst.Text = "", DBNull.Value, txtContFirst.Text)
            cmd.Parameters.Add("@ContEmail ", Data.SqlDbType.Char).Value = IIf(txtContEmail.Text = "", DBNull.Value, txtContEmail.Text)
            cmd.Parameters.Add("@ContRelationID ", Data.SqlDbType.Int).Value = IIf(ContRelationID.SelectedValue = "0", DBNull.Value, Int32.Parse(ContRelationID.SelectedItem.Value))
            cmd.Parameters.Add("@LoanAmount ", Data.SqlDbType.Decimal).Value = IIf(intLoanAmount.Text = "", DBNull.Value, intLoanAmount.Text)
            Dim iUserId As New Guid(Membership.GetUser(My.User.Name).ProviderUserKey.ToString())
            cmd.Parameters.Add("@UserKey", Data.SqlDbType.VarChar).Value = iUserId.ToString

            cnn.Open()
            Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
        Catch ex As Exception
            MsgBox(ex.ToString())
        Finally
            cnn.Close()

            lblSuccessfullyImport.Visible = True
        End Try
    End Sub

   

    Protected Sub btnManualUpload_Click(sender As Object, e As EventArgs) Handles btnManualUpload.Click
        ManualOrderUpload()
    End Sub

    Protected Sub ReportTypeID_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ReportTypeID.SelectedIndexChanged
        Dim cnn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("myprovalConnectionString").ConnectionString)
        Try
            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.Connection = cnn
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.CommandText = "dbo.GetOrderClientDueDate"
            cmd.Parameters.Add("@ReportTypeKey", Data.SqlDbType.Int).Value = Int32.Parse(ReportTypeID.SelectedItem.Value)
            cmd.Parameters.Add("@RushTypeKey", Data.SqlDbType.Int).Value = ddRushType.SelectedItem.Value
            Dim dt As New System.Data.DataTable
            cnn.Open()
            Dim dr As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
            dr.Read()
            If dr.HasRows Then
                If Not IsDBNull(dr("ClientDueDate")) Then txtClientDueDate.Text = dr("ClientDueDate")
                If Not IsDBNull(dr("ClientFee")) Then txtClientFee.Text = dr("ClientFee")
            End If
        Finally
            cnn.Close()
        End Try
    End Sub

    Protected Function GetControlThatCausedPostBack(ByVal page As Page) As Control
        Dim control As Control = Nothing

        Dim ctrlname As String = page.Request.Params.Get("__EVENTTARGET")
        If ctrlname IsNot Nothing AndAlso ctrlname <> String.Empty Then
            control = page.FindControl(ctrlname)
        Else
            For Each ctl As String In page.Request.Form
                Dim c As Control = page.FindControl(ctl)
                If TypeOf c Is System.Web.UI.WebControls.Button OrElse TypeOf c Is System.Web.UI.WebControls.ImageButton Then
                    control = c
                    Exit For
                End If
            Next ctl
        End If
        Return control

    End Function
End Class

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

19 Experts available now in Live!

Get 1:1 Help Now