本文介绍了当我使用这个代码并运行表单时,javascript现在是runnig但是当我点击图像按钮时,我的一些texboxes值是空的,现在我该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Truck_Record.aspx.cs" Inherits="Truck_Record"

    MaintainScrollPositionOnPostback="true" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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 runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        //        function benifit() {
        //            var txtFirstNumberValue = document.getElementById('txt_Distance').value;
        //            var txtSecondNumberValue = document.getElementById('txt_Fare').value;
        //            var result = parseFloat(txtFirstNumberValue) * parseFloat(txtSecondNumberValue) * 2;
        //            if (!isNaN(result)) {
        //                document.getElementById('txt_totalFare').value = result;
        //            }
        //        }


        function totalfare() {
            var txtFirstNumberValue = document.getElementById('txt_Distance').value;
            var txtSecondNumberValue = document.getElementById('txt_Fare').value;
            var result = parseFloat(txtFirstNumberValue) * parseFloat(txtSecondNumberValue) * 2;
            if (!isNaN(result)) {
                document.getElementById('txt_totalFare').value = result;
            }
        }

        function tyrereplaceafter() {
            var txtFirstNumberValue = document.getElementById('txt_tyreReplaceon').value;
            var txtSecondNumberValue = document.getElementById('txt_Distance').value;
            var result = parseFloat(txtFirstNumberValue) - parseFloat(txtSecondNumberValue);
            if (!isNaN(result)) {
                document.getElementById('txt_tyreReplaceAfter').value = result;
            }
        }

        function dieselontank() {
            var txtFirstNumberValue = document.getElementById('txt_DieselFilled').value;
            var txtSecondNumberValue = document.getElementById('txt_DieselRequired').value;
            var result = parseFloat(txtFirstNumberValue) - parseFloat(txtSecondNumberValue);
            if (!isNaN(result)) {
                document.getElementById('txt_ExtraDieselInTank').value = result;
            }
        }

        function dieselrequired() {
            var txtFirstNumberValue = document.getElementById('txt_Distance').value;
            var txtSecondNumberValue = document.getElementById('txt_Average').value;
            var result = parseFloat(txtFirstNumberValue) / parseFloat(txtSecondNumberValue);
            if (!isNaN(result)) {
                document.getElementById('txt_DieselRequired').value = result;
            }
        }

        function sub() {
            var txtFirstNumberValue = document.getElementById('txt_WeightInMines').value;
            var txtSecondNumberValue = document.getElementById('txt_WeightInFactory').value;
            var result = parseFloat(txtFirstNumberValue) - parseFloat(txtSecondNumberValue);
            if (!isNaN(result)) {
                document.getElementById('txt_Shortage').value = result;
            }
        }

        function sub1() {
            var txtFirstNumberValue = document.getElementById('txt_totalFare').value;
            var txtSecondNumberValue = document.getElementById('txt_Advance').value;
            var result = parseFloat(txtFirstNumberValue) - parseFloat(txtSecondNumberValue);
            if (!isNaN(result)) {
                document.getElementById('txt_remainingAmt').value = result;
                //            //alert(parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue));
                //            document.getElementById('changeWatcher').value = new Date();
            }
        }
        function expenses() {
            var txtFirstNumberValue = document.getElementById('txt_Puncture').value;
            var txtSecondNumberValue = document.getElementById('txt_TollTax').value;
            var txtThirdNumberValue = document.getElementById('txt_Tyre').value;
            var txtFourthNumberValue = document.getElementById('txt_Lunch').value;
            var txtFifthNumberValue = document.getElementById('txt_OtherExpenses').value;
            var result = parseFloat(txtFirstNumberValue) + parseFloat(txtSecondNumberValue) + parseFloat(txtThirdNumberValue) + parseFloat(txtFourthNumberValue) + parseFloat(txtFifthNumberValue);
            if (!isNaN(result)) {
                document.getElementById('txt_TotalExpenses').value = result;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager runat="server">
        </asp:ToolkitScriptManager>
        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
            <Items>
                <asp:MenuItem Text="LOG IN" Value="LOG IN">
                    <asp:MenuItem NavigateUrl="~/logIn.aspx" Text="Log In" Value="Log In"></asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="ORDER" Value="ORDER">
                    <asp:MenuItem NavigateUrl="~/Order.aspx" Text="Order" Value="Order"></asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/Show_Order_Details.aspx" Text="Order Details" Value="Order Details">
                    </asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="EMPLOYEE" Value="EMPLOYEE">
                    <asp:MenuItem NavigateUrl="~/Employee_Record.aspx" Text="Add Employee" Value="Add Employee">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/Show_Employee_Record.aspx" Text="Employee Details" Value="Employee Details">
                    </asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="TRUCK" Value="Truck">
                    <asp:MenuItem NavigateUrl="~/Truck_Details.aspx" Text="Add Truck Details" Value="Add Truck Details">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/Show_Truck_Details.aspx" Text="Truck Details" Value="Truck Details">
                    </asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="TRUCK CARRIER RECORD" Value="TRUCK CARRIER RECORD">
                    <asp:MenuItem NavigateUrl="~/Truck_Record.aspx" Text="Add Truck Carrier Record" Value="Add Truck Carrier Record">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/View_Truck_Record.aspx" Text="Truck Carrier Details"

                        Value="Truck Carrier Details"></asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="LOG OUT" Value="LOG OUT">
                    <asp:MenuItem NavigateUrl="~/LogOut.aspx" Text="LogOut" Value="LogOut"></asp:MenuItem>
                </asp:MenuItem>
            </Items>
        </asp:Menu>
        <table border="0" cellspacing="0" width="600" align="center">
            <tr align="center">
                <td colspan="2" style="border: 1px groove #000000">
                    Record
                </td>
            </tr>
            <tr>
                <td>
                    Order Date
                </td>
                <td>
                    <asp:TextBox ID="txt_OrderDate" runat="server" Height="24px" Width="307px"></asp:TextBox>
                    <asp:CalendarExtender ID="txt_OrderDate_CalendarExtender" runat="server" Enabled="True"

                        TargetControlID="txt_OrderDate">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Deliver Date
                </td>
                <td>
                    <asp:TextBox ID="txt_DeliveryDate" runat="server" Height="24px" Width="307px"></asp:TextBox>
                    <asp:CalendarExtender ID="txt_DeliveryDate_CalendarExtender" runat="server" Enabled="True"

                        TargetControlID="txt_DeliveryDate">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Deliver From
                </td>
                <td>
                    <asp:TextBox ID="txt_DeliveryFrom" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Deliver To
                </td>
                <td>
                    <asp:TextBox ID="txt_DeliveryTo" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Status
                </td>
                <td>
                    <asp:DropDownList ID="ddl_Status" runat="server" Height="29px" Width="138px">
                        <asp:ListItem>Going</asp:ListItem>
                        <asp:ListItem>Return</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Distance
                </td>
                <td>
                    <asp:TextBox ID="txt_Distance" runat="server" Height="24px" Width="307px" onkeyup="totalfare(); tyrereplaceafter(); dieselrequired();"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Consignor
                </td>
                <td>
                    <asp:TextBox ID="txt_Consignor" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Consignor Tin No
                </td>
                <td>
                    <asp:TextBox ID="txt_ConsignorTinNo" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Consignee
                </td>
                <td>
                    <asp:TextBox ID="txt_Consignee" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Consignee Tin No
                </td>
                <td>
                    <asp:TextBox ID="txt_ConsigneeTinNo" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Mobile No
                </td>
                <td>
                    <asp:TextBox ID="txt_MobileNO" runat="server" Height="24px" Width="307px"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_MobileNO_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_MobileNO">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Truck In Date
                </td>
                <td>
                    <asp:TextBox ID="txt_TruckInDate" runat="server" Height="24px" Width="307px"></asp:TextBox>
                    <asp:CalendarExtender ID="TextBox7_CalendarExtender" runat="server" Enabled="True"

                        TargetControlID="txt_TruckInDate">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Truck Out Date
                </td>
                <td>
                    <asp:TextBox ID="txt_TruckOutDate" runat="server" Height="24px" Width="307px"></asp:TextBox>
                    <asp:CalendarExtender ID="TextBox8_CalendarExtender" runat="server" Enabled="True"

                        TargetControlID="txt_TruckOutDate">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Truck No
                </td>
                <td>
                    <asp:TextBox ID="txt_TruckNo" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Truck Type
                </td>
                <td>
                    <asp:DropDownList ID="ddl_TruckTYpe" runat="server" Height="25px" Width="143px" AutoPostBack="True"

                        OnSelectedIndexChanged="ddl_TruckTYpe_SelectedIndexChanged">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Average
                </td>
                <td>
                    <asp:TextBox ID="txt_Average" runat="server" Height="24px" Width="307px" onkeyup="dieselrequired();"

                        ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Capacity
                </td>
                <td>
                    <asp:TextBox ID="txt_Capacity" runat="server" Height="24px" Width="307px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Tyre Replace On (km)
                </td>
                <td>
                    <asp:TextBox ID="txt_tyreReplaceon" runat="server" Height="24px" Width="307px" onkeyup="tyrereplaceafter();"

                        ReadOnly="True" OnTextChanged="txt_tyreReplaceon_TextChanged"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Tyre Replace After(km)
                </td>
                <td>
                    <asp:TextBox ID="txt_tyreReplaceAfter" runat="server" Height="24px" onkeyup="tyrereplaceafter();"

                        Width="307px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Driver Name
                </td>
                <td>
                    <asp:TextBox ID="txt_DriverName" runat="server" Height="24px" Width="307px" AutoPostBack="True"

                        OnTextChanged="txt_DriverName_TextChanged"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Licence No
                </td>
                <td>
                    <asp:TextBox ID="txt_licenceno" runat="server" Height="24px" Width="307px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Cleaner Name
                </td>
                <td>
                    <asp:TextBox ID="txt_CleanerName" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    GatePass No
                </td>
                <td>
                    <asp:TextBox ID="txt_gatePassNo" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Price (Per K.G.)
                </td>
                <td>
                    <asp:TextBox ID="txt_Price" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Weight In Mines
                </td>
                <td>
                    <asp:TextBox ID="txt_WeightInMines" runat="server" Height="24px" onkeyup="sub();"

                        Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Factory Gate No
                </td>
                <td>
                    <asp:TextBox ID="txt_FactoryGateNo" runat="server" Height="24px" Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Weight In Factory
                </td>
                <td>
                    <asp:TextBox ID="txt_WeightInFactory" runat="server" onkeyup="sub();" Height="24px"

                        Width="307px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    Shortage
                </td>
                <td class="style1">
                    <asp:TextBox ID="txt_Shortage" runat="server" Height="24px" onkeyup="sub();" Width="307px"

                        ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Advantage
                </td>
                <td>
                    <asp:TextBox ID="txt_Advantage" runat="server" Height="24px" Width="307px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Disadvantage
                </td>
                <td>
                    <asp:TextBox ID="txt_Disadvantage" runat="server" Height="24px" Width="307px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Fare (Per Km)
                </td>
                <td>
                    <asp:TextBox ID="txt_Fare" runat="server" Height="24px" Width="307px" onkeyup="totalfare();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="TextBox17_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_Fare">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Total_fare
                </td>
                <td>
                    <asp:TextBox ID="txt_totalFare" runat="server" Height="24px" Width="307px" onkeyup="totalfare(); sub1();"

                        ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Advance
                </td>
                <td>
                    <asp:TextBox ID="txt_Advance" runat="server" Height="24px" Width="307px" onkeyup="sub1();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_Advance_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_Advance">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Remaining Amount
                </td>
                <td>
                    <asp:TextBox ID="txt_remainingAmt" runat="server" Height="24px" ReadOnly="True" Width="307px"

                        onkeyup="sub1();"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Diesel Required
                </td>
                <td>
                    <asp:TextBox ID="txt_DieselRequired" runat="server" Height="24px" Width="307px" onkeyup="dieselrequired(); dieselontank();"

                        ReadOnly="True"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_DieselRequired_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_DieselRequired">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Diesel Filled
                </td>
                <td>
                    <asp:TextBox ID="txt_DieselFilled" runat="server" Height="24px" Width="307px" onkeyup="sub1(); dieselontank();"

                        AutoPostBack="True"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_DieselFilled_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_DieselFilled">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Extra Diesel in Tank
                </td>
                <td>
                    <asp:TextBox ID="txt_ExtraDieselInTank" runat="server" Height="24px" Width="307px"

                        onkeyup="dieselontank();" ReadOnly="True" AutoPostBack="True" ></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_ExtraDieselInTank_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_ExtraDieselInTank">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Expenses
                </td>
                <td>
                    <asp:ImageButton ID="ImageButton1" runat="server" Height="33px" Width="107px" ImageUrl="~/Uploads/newstuf_e0.gif"

                        OnClick="ImageButton1_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbl_Puncture" runat="server" Text="Puncture"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txt_Puncture" runat="server" Height="24px" Width="307px" onkeyup="expenses();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_Puncture_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_Puncture">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbl_TollTax" runat="server" Text="Toll Tax"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txt_TollTax" runat="server" Height="24px" Width="307px" onkeyup="expenses();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_TollTax_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_TollTax">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbl_Tyre" runat="server" Text="Tyre"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txt_Tyre" runat="server" Height="24px" Width="307px" onkeyup="expenses();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_Tyre_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_Tyre">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbl_Lunch" runat="server" Text="Lunch"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txt_Lunch" runat="server" Height="24px" Width="307px" onkeyup="expenses();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_Lunch_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_Lunch">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:Label ID="lbl_OthrExpenses" runat="server" Text="Other Expenses "></asp:Label>
                </td>
                <td class="style3">
                    <asp:TextBox ID="txt_OtherExpenses" runat="server" Height="24px" Width="307px" onkeyup="expenses();"></asp:TextBox>
                    <asp:FilteredTextBoxExtender ID="txt_OtherExpenses_FilteredTextBoxExtender" FilterType="Numbers"

                        runat="server" Enabled="True" TargetControlID="txt_OtherExpenses">
                    </asp:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:Label ID="lbl_TotalExpenses" runat="server" Text="Total Expenses "></asp:Label>
                </td>
                <td class="style3">
                    <asp:TextBox ID="txt_TotalExpenses" runat="server" Height="24px" Width="307px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr align="center">
                <td colspan="2">
                    <asp:Button ID="btn_Submit" runat="server" Style="font-weight: 700" Text="Submit"

                        OnClick="btn_Submit_Click" />
                </td>
            </tr>
            <tr align="center">
                <td colspan="2">
                    <asp:Label ID="lbl_Msg" runat="server" ForeColor="#FF3300"></asp:Label>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>











when i am using this code and runs the form the javascript is currectly runnig but when i click on image button my some texboxes value is being empty, now what can i do






when i am using this code and runs the form the javascript is currectly runnig but when i click on image button my some texboxes value is being empty, now what can i do

推荐答案

<asp:ToolkitScriptManager runat="server">
<Scripts>
        <asp:ScriptReference runat="server" Path="~/Scripts/yourscript.js"/>
        </Scripts>
      </asp:ToolkitScriptManager>


这篇关于当我使用这个代码并运行表单时,javascript现在是runnig但是当我点击图像按钮时,我的一些texboxes值是空的,现在我该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 20:08