c# - casting, converting, and input from textbox controls -


Working on some .aspx.cs code and decided that I would forget to change a text box value to a usable integer or decimal. Please warn me I'm very new to .asp I wish I could say the same for C, the value going to my text box (strawberry_textbox) is "1", which I guess I can reach with .text property I am Which I then read pars error in an int that format exception was coded by the user code.

My second question: Can I work on a session variable?

  secure void submit_order_button_click (object sender, EventArgs e) {int strawberryp; Int strawberries; Decimal plus 1 = decimals Purse (moneybox1.Text); Decimal plus 2 = decimals Purse (moneybox2.Text); Decimal plus 3 = decimals Purse (moneybox3.Text); Decimal plus 4 = decimals Purse (moneybox4.Text); Decimal money 5 = decimal Purse (moneybox5.Text); Strawberryp = int.Parse (strawberryp_Textbox.Text); // The problem is right here! Strawberry = Int. Percy (strawberry .text); // need fix int strawberryc = int.Parse (strawberryc_Textbox.Text); // fixed int berryp = int.Parse (berryp_Textbox.Text); // fixed int raspberryp = int.Parse (raspberryp_Textbox.Text); / Fixed decimal sub-sum = (wealth 1 * strawberries) + (plus 2 * strawberries) + (plus 3 * strawberries) + (plus 4 * bit) + (money 5 * raspberries); // Check to check if you can get the decimal and multiplication DCMML !! Session ["passmysubtotal"] = sub-totals; //TextBox2.Text; (Strawberryp_Textbox.Text); // TextBox4.Text; Add_my_order_button.Enabled = true; Add_my_order_button.Visible = true; Submit_order_button.Enabled = false; Submit_order_button.Visible = false; Strawberry_typebox Readonly = false; Strawberrys_textbox.ReadOnly = false; Strawberry citium box. Read only = false; Berryp_Textbox.ReadOnly = false; Raspberryp_Textbox.ReadOnly = false; Response.Redirect ("reciept.aspx"); }  

Thanks for the help

Post the results of the insert A console. WriteLine (strawberryp_Textbox.Text); Just before the line of your code is a "problem ..." comment if you run the app under the Visual Studio web server (usually by debugging-F5), then output the output in Visual Studio Should show. This can help to verify that only one letter '1' is in the text property of that text box.

In addition, one of the best practices is to try TryParse instead of parse so that you can more effectively control the answer to the errors. expected value.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -