Click here to Skip to main content
15,900,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form that I am doing Auto Calculations when the textbox looses focus. I have a textbox set to AutoPostBack when it looses focus in order to calculate the fields that are needed. Every time a user puts in the last number and clicks to the next field it refreshes the form back to the top. It does the calculations I just want to know is there a way to stop the page from refreshing back to the top and still do the calculations?

Here is the Page Code:

ASP.NET
<%@ Page Language="C#" AutoEventWireup="True" Inherits="FinancialProfileFormA" Codebehind="FinancialProfileFormA.aspx.cs" %>

<!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>
    <style type="text/css">
        .style1
        {
            font-size: x-large;
            text-align: center;
        }
        .style2
        {
            width: 100%;
        }
        .style4
        {
            width: 737px;
            text-align: right;
            font-size: large;
        }
        .style5
        {
            width: 20px;
        }
        .style6
        {
            font-size: large;
            width: 495px;
        }
        .style7
        {
            width: 495px;
            font-weight: bold;
        }
        .style8
        {
            font-size: large;
        }
        .style9
        {
            width: 20px;
            height: 23px;
        }
        .style10
        {
            width: 495px;
            height: 23px;
            font-weight: bold;
        }
        .style11
        {
            height: 23px;
        }
        .style18
        {
            font-weight: bold;
        }
        .style19
        {
            width: 584px;
            text-align: center;
        }
        .style20
        {
            font-size: x-large;
            width: 212px;
        }
        .style21
        {
            width: 212px;
            font-weight: bold;
        }
        .style22
        {
            width: 212px;
            height: 23px;
            font-weight: bold;
        }
        .style23
        {
            font-size: small;
        }
        .style24
        {
            font-size: small;
            font-weight: normal;
        }
        .newStyle1
        {
        }
        .style25
        {
            width: 736px;
        }
        .style26
        {
            text-align: right;
            width: 703px;
        }
        .style3
        {
            width: 100%;
        }
        .style35
        {
            width: 469px;
            font-weight: bold;
            font-size: large;
        }
        .style36
        {
            width: 469px;
        }
        .style37
        {
            font-size: large;
            width: 433px;
        }
        .style38
        {
            font-size: x-large;
            width: 190px;
        }
        .style39
        {
            width: 190px;
        }
        .style40
        {
            width: 645px;
            height: 23px;
            text-align: right;
        }
        .style41
        {
            width: 645px;
            height: 23px;
            font-weight: bold;
            text-align: right;
        }
        .style42
        {
            height: 23px;
            width: 190px;
        }
        .style47
        {
            font-size: large;
            text-align: center;
        }
        .style48
        {
            font-size: xx-large;
        }
        .style49
        {
            font-size: x-large;
        }
        .style50
        {
            width: 585px;
            height: 137px;
        }
        .style51
        {
            font-weight: bold;
            font-size: x-large;
            text-align: center;
        }
        .style52
        {
            width: 670px;
        }
    </style>
    <script language="javascript" type="text/javascript">
// <![CDATA[

        function Reset1_onclick() {

        }

// 
    </script>
</head>
<body background="Images/bkg-blu.jpg" bgcolor="#3399ff">
    <form id="form1"  runat="server">
    <div class="style1">
    
        <div style="text-align: left">
                                                                                                                     <table 
                class="style2">
                <tr>
                    <td style="text-align: center">
                        <img class="style50" src="Images/buildout_header.jpg" /></td>
                </tr>
            </table>
                                                                           
                                                                                                                                      
                                                                    
        </div>
    
        
        <span class="style48">
        <br />
        Financial Profile </span></div>
    <br />
    <br />
                
    <br />
    <asp:TextBox ID="TextBoxINST_ID" runat="server" Enabled="False" ReadOnly="True" 
        Visible="False"></asp:TextBox>
    <br />
    <table class="style2">
        <tr>
            <td style="text-align: center">
                <asp:Label ID="lblSchool" runat="server" CssClass="style51"></asp:Label>
            </td>
        </tr>
    </table>
    <table class="style2">
        <tr>
            <td class="style52" style="text-align: right">
                <asp:Label ID="lblCity" runat="server" CssClass="style51"></asp:Label>
                ,</td>
            <td>
 <asp:Label ID="lblState" runat="server" CssClass="style51"></asp:Label>
            </td>
        </tr>
    </table>
    <br />
    <br />
    <br />
    <br />
    <table class="style2">
        <tr>
            <td class="style4">
                Total Revenues and Other Additions <span class="style23">(IPEDS 
                Part B, Line 25)</span></td>
            <td>
                 <asp:TextBox ID="TextBoxTROA" runat="server" style="text-align: right" 
                    Width="180px" ToolTip="IPEDS Part B, line 25"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server" 
                    ControlToValidate="TextBoxTROA" 
                    ErrorMessage="Please Enter Total Revenues and Other Additions" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
    </table>
    <br />
     <br />
    <table class="style2">
        <tr>
            <td class="style26">
                  </td>
            <td>
                         </td>
        </tr>
    </table>
    <table class="style2">
        <tr>
            <td class="style25">
                                                                                                                                  
                </td>
            <td>
                 </td>
        </tr>
    </table>
    <br />
    <br />
    <table class="style2">
        <tr>
            <td class="style5">
                 </td>
            <td class="style6">
                Function/Classification</td>
            <td class="style20">
                 </td>
            <td class="style8">
                 </td>
        </tr>
        <tr>
            <td class="style5">
                 </td>
            <td class="style6">
                 </td>
            <td class="style20">
                           2012</td>
            <td class="style8">
                              
                <span class="style49">2013</span></td>
        </tr>
        <tr>
            <td class="style5">
                1</td>
            <td class="style7">
                Instruction <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYInstr" runat="server" Enabled="False" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxInstr" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 01, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server" 
                    ControlToValidate="TextBoxInstr" ErrorMessage="You Must Enter Instruction!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style9">
                2</td>
            <td class="style10">
                Research <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style22">
                <asp:TextBox ID="TextBoxLYRes" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td class="style11">
                <asp:TextBox ID="TextBoxRes" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 02, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator19" runat="server" 
                    ControlToValidate="TextBoxRes" ErrorMessage="You Must Enter Research!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                3</td>
            <td class="style7">
                Public Service<span class="style24"> (IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYPubS" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxPubS" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 03, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator20" runat="server" 
                    ControlToValidate="TextBoxPubS" ErrorMessage="You Must Enter Public Service!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                4</td>
            <td class="style7">
                Academic Support<span class="style24"> (IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYAcad" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxAcad" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 05, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator21" runat="server" 
                    ControlToValidate="TextBoxAcad" 
                    ErrorMessage="You Must Enter Academic Support!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                5</td>
            <td class="style7">
                Student Services <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYStudS" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxStudS" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 06, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator22" runat="server" 
                    ControlToValidate="TextBoxStudS" 
                    ErrorMessage="You Must Enter Student Services!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                6</td>
            <td class="style7">
                Institutional Support<span class="style24"> (IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYInstiS" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxInstiS" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 07, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator23" runat="server" 
                    ControlToValidate="TextBoxInstiS" 
                    ErrorMessage="You Must Enter Institutional Support!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                7</td>
            <td class="style7">
                Operation & Maintenance of Plant <span class="style24">(IPEDS Part C, Line 
                01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYOperM" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxOperM" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 08, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator24" runat="server" 
                    ControlToValidate="TextBoxOperM" 
                    ErrorMessage="You Must Enter Operation & Maintenance of Plant!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                8</td>
            <td class="style7">
                Scholarships & Fellowships, Excluding Discounts & Allowances
                <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYSFEDA" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxSFEDA" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 10, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator25" runat="server" 
                    ControlToValidate="TextBoxSFEDA" 
                    ErrorMessage="You Must Enter Scholarships & Fellowships!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                9</td>
            <td class="style7">
                Auxiliary Enterprises <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYAuxE" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxAuxE" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 11, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator26" runat="server" 
                    ControlToValidate="TextBoxAuxE" 
                    ErrorMessage="You Must Enter Auxiliary Enterprises!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                10</td>
            <td class="style7">
                Hospital Services <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYHosS" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxHosS" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 12, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator27" runat="server" 
                    ControlToValidate="TextBoxHosS" 
                    ErrorMessage="You Must Enter Hospital Services!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                11</td>
            <td class="style7">
                Independent Operations <span class="style24">(IPEDS Part C, Line 01, Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYIndeO" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxIndeO" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 13, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator28" runat="server" 
                    ControlToValidate="TextBoxIndeO" 
                    ErrorMessage="You Must Enter Independent Operations!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                12</td>
            <td class="style7">
                Other Expenses & Deductions <span class="style24">(IPEDS Part C, Line 01, 
                Column 01)</span></td>
            <td class="style21">
                <asp:TextBox ID="TextBoxLYOED" runat="server" Enabled="False" ReadOnly="True" 
                    Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="TextBoxOED" runat="server" Width="180px" 
                    ToolTip="IPEDS Part C, Line 14, Column 01"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator29" runat="server" 
                    ControlToValidate="TextBoxOED" 
                    ErrorMessage="You Must Enter Other Expenses & Deductions!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        </table>
    <br />
    <br />
    <br />
    <table class="style2">
        <tr>
            <td class="style47">
                                          <span 
                    class="style49"> 
                Financial Indicators</span></td>
        </tr>
    </table>
    <br />
    <br />
    <table class="style3">
        <tr>
            <td class="style37">
                 </td>
            <td class="style38">
                            2012</td>
            <td class="style35">
                </td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYTA" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTA" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Total Liabilities</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYTL" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTL" runat="server" Width="180px" AutoPostBack="True" 
                    ontextchanged="TextBoxTL_TextChanged"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__strong__^Total Net Assets</strong__^</td>
            <td class="style39">
                 </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTNA" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Nonexpendable/Permanently Restricted Net Assets</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYNPRNA" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxNPRNA" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Expendable/Temporarily Restricted Net Assets</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYETRNA" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxETRNA" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Total Unrestricted Net Assets <span class="style23">(Unrestricted net assets 
                Plus capital assets, net)</span></td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYTUNA" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTUNA" runat="server" Width="180px" AutoPostBack="True" 
                    ontextchanged="TextBoxTUNA_TextChanged"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Total Revenue</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYTR" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTR" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Tuition and Fees, Net</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYTFN" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTFN" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Current Debt</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYCD" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxCD" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Long-term Debt</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYLTD" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxLTD" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style37">
                ^__b__^Total Net Assets</td>
            <td class="style39">
                <asp:TextBox ID="TextBoxLYTNA" runat="server" Width="180px" Enabled="False" 
                    ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style36">
                <asp:TextBox ID="TextBoxTNA2" runat="server" Width="180px"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator1" runat="server" 
                    ControlToCompare="TextBoxTNA" ControlToValidate="TextBoxTNA2" 
                    ErrorMessage="The Entry Does Not Match Each Other!!" ForeColor="Red" 
                    style="font-weight: 700"></asp:CompareValidator>
            </td>
        </tr>
    </table>
    <br />
    <br />
    <br />
    <br />
    <table class="style3">
        <tr>
            <td class="style40">
                ^__strong__^Name</td>
            <td class="style42">
                <asp:TextBox ID="TextBoxFullN" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ControlToValidate="TextBoxFullN" ErrorMessage="Please Give Your Full Name!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style40">
                ^__strong__^Title</td>
            <td class="style42">
                <asp:TextBox ID="TextBoxTitle" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="TextBoxTitle" ErrorMessage="Please Give Your Title!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style40">
                ^__strong__^Institution</td>
            <td class="style42">
                <asp:Label ID="lblSchool2" runat="server"></asp:Label>
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style40">
                ^__strong__^Mailing ^__strong>Address</td>
            <td class="style42">
                <asp:TextBox ID="TextBoxMA" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                    ControlToValidate="TextBoxMA" 
                    ErrorMessage="Please Give Your Mailing Address!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style41">
                 </td>
            <td class="style42">
                 </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style40">
                ^__strong>Telephone Number</td>
            <td class="style42">
                <asp:TextBox ID="TextBoxTN" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                    ControlToValidate="TextBoxTN" 
                    ErrorMessage="Please Give Your Telephone Number!!!" ForeColor="Red" 
                    CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style40">
                ^__strong>Fax Number</td>
            <td class="style42">
                <asp:TextBox ID="TextBoxFN" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" 
                    ControlToValidate="TextBoxFN" ErrorMessage="Please Give Your  Fax Number!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style40">
                ^__strong>Email Address</td>
            <td class="style42">
                <asp:TextBox ID="TextBoxEA" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" 
                    ControlToValidate="TextBoxEA" ErrorMessage="Please Give Your Email Address!!!" 
                    ForeColor="Red" CssClass="style18"></asp:RequiredFieldValidator>
            </td>
        </tr>
    </table>
    <br />
    <br />
    <br />
    <br />
    <table class="style2">
        <tr>
            <td class="style19">
                <asp:Button ID="ButtonSubmit" runat="server" onclick="ButtonSubmit_Click" 
                    Text="Submit" Width="100px" style="text-align: center" />
            </td>
            <td>
                <input id="Reset1" type="reset" value="Clear Form" 
                     önclick="return Reset1_onclick()" /></td>
            <td>
                <asp:Button ID="ButtonPrint" runat="server" Text="Print" Width="100px" />
            </td>
        </tr>
    </table>
    </form>
    </body>
</html>



Here is My C# Code:

C#
using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Drawing.Printing;

public partial class FinancialProfileFormA : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        ButtonPrint.Attributes.Add("onclick", "window.print(); return false");

        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con.Open();
        SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con2.Open();
        SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con3.Open();

        TextBoxINST_ID.Text = Session["inst_id"].ToString();
        SqlCommand scmd = new SqlCommand("Select INST_ID, LongName, City, State from TableCOCINST where INST_ID = '" + TextBoxINST_ID.Text + "'", con);
        SqlCommand scmd2 = new SqlCommand("Select INST_ID, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT from TableFIN2012 where INST_ID = '" + TextBoxINST_ID.Text + "'", con2);
        SqlCommand scmd3 = new SqlCommand("Select INST_ID, TOTAL_REVE, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, EXPENDABLE, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT from TableFIN2013 where INST_ID = '" + TextBoxINST_ID.Text + "'", con3);
        SqlDataReader dr = scmd.ExecuteReader();
        SqlDataReader dr2 = scmd2.ExecuteReader();
        SqlDataReader dr3 = scmd3.ExecuteReader();

        if (dr.Read())
        if (dr2.Read())
        if (dr3.Read())
            {
                lblCity.Text = dr["City"].ToString();
                lblState.Text = dr["State"].ToString();
                lblSchool.Text = dr["LongName"].ToString();
                lblSchool2.Text = dr["LongName"].ToString();
                TextBoxLYInstr.Text = dr2["INSTRUCTIO"].ToString();
                TextBoxLYRes.Text = dr2["RESEARCH"].ToString();
                TextBoxLYPubS.Text = dr2["PUBLIC_SER"].ToString();
                TextBoxLYAcad.Text = dr2["ACADEMIC_S"].ToString();
                TextBoxLYStudS.Text = dr2["STUDENT_SE"].ToString();
                TextBoxLYInstiS.Text = dr2["INSTITUTIO"].ToString();
                TextBoxLYOperM.Text = dr2["PHYSICAL_P"].ToString();
                TextBoxLYSFEDA.Text = dr2["SCHOLARSHI"].ToString();
                TextBoxLYAuxE.Text = dr2["AUXILIARY_"].ToString();
                TextBoxLYHosS.Text = dr2["HOSPITALS"].ToString();
                TextBoxLYIndeO.Text = dr2["INDEPENDEN"].ToString();
                TextBoxLYOED.Text = dr2["OTHEREXP"].ToString();
                TextBoxLYTA.Text = dr2["TOTASSETS"].ToString();
                TextBoxLYTL.Text = dr2["TOTLIABILITY"].ToString();
                TextBoxLYNPRNA.Text = dr2["NoNEXPPERMRESASSETS"].ToString();
                TextBoxLYTUNA.Text = dr2["UNRNETASSETS"].ToString();
                TextBoxLYTR.Text = dr2["TOTALREV"].ToString();
                TextBoxLYTFN.Text = dr2["TUITFEES"].ToString();
                TextBoxLYCD.Text = dr2["CURRDEBT"].ToString();
                TextBoxLYLTD.Text = dr2["LONGTERMDEBT"].ToString();

                TextBoxTROA.Text = dr3["TOTAL_REVE"].ToString();
                TextBoxInstr.Text = dr3["INSTRUCTIO"].ToString();
                TextBoxRes.Text = dr3["RESEARCH"].ToString();
                TextBoxPubS.Text = dr3["PUBLIC_SER"].ToString();
                TextBoxAcad.Text = dr3["ACADEMIC_S"].ToString();
                TextBoxStudS.Text = dr3["STUDENT_SE"].ToString();
                TextBoxInstiS.Text = dr3["INSTITUTIO"].ToString();
                TextBoxOperM.Text = dr3["PHYSICAL_P"].ToString();
                TextBoxSFEDA.Text = dr3["SCHOLARSHI"].ToString();
                TextBoxAuxE.Text = dr3["AUXILIARY_"].ToString();
                TextBoxHosS.Text = dr3["HOSPITALS"].ToString();
                TextBoxIndeO.Text = dr3["INDEPENDEN"].ToString();
                TextBoxOED.Text = dr3["OTHEREXP"].ToString();
                TextBoxTA.Text = dr3["TOTASSETS"].ToString();
                TextBoxTL.Text = dr3["TOTLIABILITY"].ToString();
                TextBoxNPRNA.Text = dr3["NoNEXPPERMRESASSETS"].ToString();
                TextBoxETRNA.Text = dr3["EXPENDABLE"].ToString();
                TextBoxTUNA.Text = dr3["UNRNETASSETS"].ToString();
                TextBoxTR.Text = dr3["TOTALREV"].ToString();
                TextBoxTFN.Text = dr3["TUITFEES"].ToString();
                TextBoxCD.Text = dr3["CURRDEBT"].ToString();
                TextBoxLTD.Text = dr3["LONGTERMDEBT"].ToString();

                

            }
        dr.Close();
        con.Close();
        dr2.Close();
        con2.Close();
        dr3.Close();
        con3.Close();

    }

    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con.Open();


        SqlCommand cmd = new SqlCommand("Insert into TableFIN2013 (INST_ID, TOTAL_REVE, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, EXPENDABLE, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT) values (@INST_ID, @TOTAL_REVE, @INSTRUCTIO, @RESEARCH, @PUBLIC_SER, @ACADEMIC_S, @STUDENT_SE, @INSTITUTIO, @PHYSICAL_P, @SCHOLARSHI, @AUXILIARY_, @HOSPITALS, @INDEPENDEN, @OTHEREXP, @TOTASSETS, @TOTLIABILITY, @NoNEXPPERMRESASSETS, @EXPENDABLE, @UNRNETASSETS, @TOTALREV, @TUITFEES, @CURRDEBT, @LONGTERMDEBT)", con);
        

        cmd.CommandType = CommandType.Text;

        cmd.Parameters.AddWithValue("@INST_ID", TextBoxINST_ID.Text);
        cmd.Parameters.AddWithValue("@TOTAL_REVE", TextBoxTROA.Text);
        cmd.Parameters.AddWithValue("@INSTRUCTIO", TextBoxInstr.Text);
        cmd.Parameters.AddWithValue("@RESEARCH", TextBoxRes.Text);
        cmd.Parameters.AddWithValue("@PUBLIC_SER", TextBoxPubS.Text);
        cmd.Parameters.AddWithValue("@ACADEMIC_S", TextBoxAcad.Text);
        cmd.Parameters.AddWithValue("@STUDENT_SE", TextBoxStudS.Text);
        cmd.Parameters.AddWithValue("@INSTITUTIO", TextBoxInstiS.Text);
        cmd.Parameters.AddWithValue("@PHYSICAL_P", TextBoxOperM.Text);
        cmd.Parameters.AddWithValue("@SCHOLARSHI", TextBoxSFEDA.Text);
        cmd.Parameters.AddWithValue("@AUXILIARY_", TextBoxAuxE.Text);
        cmd.Parameters.AddWithValue("@HOSPITALS", TextBoxHosS.Text);
        cmd.Parameters.AddWithValue("@INDEPENDEN", TextBoxIndeO.Text);
        cmd.Parameters.AddWithValue("@OTHEREXP", TextBoxOED.Text);
        cmd.Parameters.AddWithValue("@TOTASSETS", TextBoxTA.Text);
        cmd.Parameters.AddWithValue("@TOTLIABILITY", TextBoxTL.Text);
        cmd.Parameters.AddWithValue("@NoNEXPPERMRESASSETS", TextBoxNPRNA.Text);
        cmd.Parameters.AddWithValue("@EXPENDABLE", TextBoxETRNA.Text);
        cmd.Parameters.AddWithValue("@UNRNETASSETS", TextBoxTUNA.Text);
        cmd.Parameters.AddWithValue("@TOTALREV", TextBoxTR.Text);
        cmd.Parameters.AddWithValue("@TUITFEES", TextBoxTFN.Text);
        cmd.Parameters.AddWithValue("@CURRDEBT", TextBoxCD.Text);
        cmd.Parameters.AddWithValue("@LONGTERMDEBT", TextBoxLTD.Text);


        cmd.ExecuteNonQuery();
        con.Close();
        Response.Redirect("FinancialProfileFormA.aspx");
    }

    protected void TextBoxTL_TextChanged(object sender, EventArgs e)
    {
        int a = Convert.ToInt32(TextBoxTA.Text);
        int b = Convert.ToInt32(TextBoxTL.Text);
        TextBoxTNA.Text = Convert.ToString(a - b); 
    }

    protected void TextBoxTUNA_TextChanged(object sender, EventArgs e)
    {
        int a = Convert.ToInt32(TextBoxNPRNA.Text);
        int b = Convert.ToInt32(TextBoxETRNA.Text);
        int c = Convert.ToInt32(TextBoxTUNA.Text);
        TextBoxTNA2.Text = Convert.ToString(a + b + c); 
    }
}
Posted

1 solution

Page.MaintainScrollPositionOnPostback = true; should take you back to the same position on the screen, but you could use AJAX to avoid page reload, It will also improve your response time.
 
Share this answer
 
Comments
Computer Wiz99 11-Nov-13 9:54am    
Ok, Thanks. Now on which part of my code does this go? On the C# or the Source code page?
Kamalsingh Saini 11-Nov-13 10:21am    
You can set this in code behind or in .aspx page, Please follow this link http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback(v=vs.110).aspx
Computer Wiz99 11-Nov-13 10:22am    
Ok. Thanks. I will. I think it would be better to put it in the Page_Load right?
Kamalsingh Saini 11-Nov-13 10:36am    
yp you can.
Computer Wiz99 11-Nov-13 14:15pm    
Ok. The code you gave me, "Page.MaintainScrollPositionOnPostback = true;", where should I put it in my .aspx page?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900