Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a web form that has 21 textboxes that are populated with data from a database. I set a masking to these textboxes and when I debug it the masking does not work. Am I forgetting something? The masking works for the other textboxes that you would have to enter data but not the populated ones. Please help. Thanks.

Here is the masking code:

HTML
<script src="Scripts/jquery-2.1.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery.maskMoney.js" type="text/javascript"></script>
    <script type='text/javascript'>
        $(document).ready(function () {
            $("#TextBoxLYTROA").maskMoney();
            $("#TextBoxLYInstr").maskMoney();
            $("#TextBoxRes").maskMoney();
            $("#TextBoxPubS").maskMoney();
            $("#TextBoxAcad").maskMoney();
            $("#TextBoxStudS").maskMoney();
            $("#TextBoxInstiS").maskMoney();
            $("#TextBoxOperM").maskMoney();
            $("#TextBoxAuxE").maskMoney();
            $("#TextBoxHosS").maskMoney();
            $("#TextBoxIndeO").maskMoney();
            $("#TextBoxOED").maskMoney();
            $("#TextBoxTA").maskMoney();
            $("#TextBoxTL").maskMoney();
            $("#TextBoxTUNA").maskMoney();
            $("#TextBoxETRNA").maskMoney();
            $("#TextBoxNPRNA").maskMoney();
            $("#TextBoxTR").maskMoney();
            $("#TextBoxTFN").maskMoney();
            $("#TextBoxCD").maskMoney();
            $("#TextBoxLTD").maskMoney();  

        });
    </script>


Here is my populated code:

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

            SqlCommand scmd4 = new SqlCommand("Select INST_ID, TOTAL_REVE, DATE, 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, TOTALNETASSETS from Table3 where IUser_ID = '" + TextBoxIUser_ID.Text + "'", con4);
            SqlDataReader dr4 = scmd4.ExecuteReader();

            if (dr4.Read())
            {
                TextBoxLYTROA.Text = dr4["TOTAL_REVE"].ToString();
                TextBoxLYInstr.Text = dr4["INSTRUCTIO"].ToString();
                TextBoxLYRes.Text = dr4["RESEARCH"].ToString();
                TextBoxLYPubS.Text = dr4["PUBLIC_SER"].ToString();
                TextBoxLYAcad.Text = dr4["ACADEMIC_S"].ToString();
                TextBoxLYStudS.Text = dr4["STUDENT_SE"].ToString();
                TextBoxLYInstiS.Text = dr4["INSTITUTIO"].ToString();
                TextBoxLYOperM.Text = dr4["PHYSICAL_P"].ToString();
                TextBoxLYSFEDA.Text = dr4["SCHOLARSHI"].ToString();
                TextBoxLYAuxE.Text = dr4["AUXILIARY_"].ToString();
                TextBoxLYHosS.Text = dr4["HOSPITALS"].ToString();
                TextBoxLYIndeO.Text = dr4["INDEPENDEN"].ToString();
                TextBoxLYOED.Text = dr4["OTHEREXP"].ToString();
                TextBoxLYTA.Text = dr4["TOTASSETS"].ToString();
                TextBoxLYTL.Text = dr4["TOTLIABILITY"].ToString();
                TextBoxLYNPRNA.Text = dr4["NoNEXPPERMRESASSETS"].ToString();
                TextBoxLYETRNA.Text = dr4["EXPENDABLE"].ToString();
                TextBoxLYTUNA.Text = dr4["UNRNETASSETS"].ToString();
                TextBoxLYTR.Text = dr4["TOTALREV"].ToString();
                TextBoxLYTFN.Text = dr4["TUITFEES"].ToString();
                TextBoxLYCD.Text = dr4["CURRDEBT"].ToString();
                TextBoxLYLTD.Text = dr4["LONGTERMDEBT"].ToString();
                TextBoxLYTNA.Text = dr4["TOTALNETASSETS"].ToString();
            }
            con4.Close();
            dr4.Close();
        }
    }
Posted
Updated 24-Jul-14 3:21am
v2
Comments
Prakriti Goyal 24-Jul-14 9:17am    
Check the name of the textboxes..
First two differ in js code and .cs code
Computer Wiz99 24-Jul-14 9:26am    
Thanks. I will check that and make changes.
Computer Wiz99 24-Jul-14 9:32am    
I changed the names of the textboxes and the same thing is happening, Nothing. No masked numbers in the populated textbox.
Richard Deeming 24-Jul-14 9:18am    
Your code is susceptible to SQL Injection[^]. You need to use a parameterized query instead.

Also, check the client ID of the controls; it probably won't be exactly the same as the server ID.
Computer Wiz99 24-Jul-14 9:31am    
Thanks, I know about the SQL Injections. This is just a test that I am show some kids in this summer program.

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