Click here to Skip to main content
11,505,486 members (67,865 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
i have tow text boxes when i entered the values in the page the result should be displayed in the same page
Posted 4-Oct-12 7:30am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

double num1, num2;
private void button1_Click(object sender, EventArgs e)
{
    num1 = Convert.ToDouble(textBox1.Text);
    num2 = Convert.ToDouble(textBox2.Text);
    label1.Text = Convert.ToString(num1 * num2);
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Friend, on button click event, take the value of both text box like TextBox1.Text and convert them into double/int data type, multiply both the textbox values and assign the value on label as "Label1.Text =(Convert.ToInt(TextBox1.Text)*Convert.ToInt(TextBox2.Text)).ToString();"

Thanks,
Ambesha
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

<body>
    <form id="form1" runat="server">
    <div>
    <asp:label id="lblNumber1" runat="server" text="Enter first value:" xmlns:asp="#unknown"></asp:label>
    <asp:textbox id="txtNumber1" runat="server" xmlns:asp="#unknown"></asp:textbox>
    
 
    <asp:label id="lblNumber2" runat="server" text="Enter second value:" xmlns:asp="#unknown"></asp:label>
    <asp:textbox id="txtNumber2" runat="server" xmlns:asp="#unknown"></asp:textbox>
    
 
    <asp:button id="btnMultiplication" runat="server" text="Multiplication" onclick="OnBtnMultiplicationClick" xmlns:asp="#unknown"></asp:button>
    
<asp:label id="lblMultiplication" runat="server" xmlns:asp="#unknown"></asp:label>
    </div>
    
    </form>
</body>

Now on code behind (test.aspx.cs):
----------------------------------
 protected void OnBtnMultiplicationClick(object sender, EventArgs e)
        {
            int num1=Convert.ToInt32(txtNumber1.Text);
            int num2 = Convert.ToInt32(txtNumber2.Text);
            lblMultiplication.Text = (num1 * num2).ToString();
 
        }
**Validation is not done so check for Null or empty value.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 1,067
1 Maciej Los 575
2 Peter Leow 540
3 F-ES Sitecore 525
4 DamithSL 470


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100