I have two TextBox.
textbox1 ,textbox2
write csharp code addition of two textbox display in label
label.text=texbox1+textbox2
plz write csharp code.............
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 17, 2014, 2:35 AM EDT
AshishRank #8,652 · 218 reputationPosted Apr 16, 2014, 9:20 PM EDT
Srikanth Reddy142 reputationPosted Apr 16, 2014, 9:37 PM EDT
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text);
int b = Convert.ToInt32(TextBox2.Text);
label.text=(a+b).ToString();
}
JAYRAMRank #7,836 · 233 reputationPosted Apr 16, 2014, 10:04 PM EDT
textbox2 value=2
shows error like incorrect string formot
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 16, 2014, 10:13 PM EDT
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Add
{
public partial class calci : Form
{
public calci()
{
InitializeComponent();
}
private void But_Add_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(Txt_1.Text );
int b = Convert.ToInt32(Txt_2.Text);
int c = a + b;
Ans.Text = c.ToString();
}
} }
Srikanth Reddy142 reputationPosted Apr 16, 2014, 10:26 PM EDT
var b=convert.ToDecimal(textbox2.text)
JAYRAMRank #7,836 · 233 reputationPosted Apr 16, 2014, 10:26 PM EDT
like 10.5
9.2
3.9
Srikanth Reddy142 reputationPosted Apr 16, 2014, 10:29 PM EDT
var b=convert.ToDecimal(textbox2.text)
it will work
if you got correct answer click correct answer
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 16, 2014, 10:30 PM EDT
System.Decimal d = System.Decimal.Add(4.61m, 4.61m);
result is 9.22
AmanRank #607 · 3.9K reputationPosted Apr 16, 2014, 10:54 PM EDT
I am embedding the Source Code also you can download it.
decimal add;
add=Convert.ToDecimal( textBox1.Text) +Convert.ToDecimal( textBox2.Text);
label3.Text = add.ToString();
Ranjit PowarRank #553 · 4.4K reputationPosted Apr 16, 2014, 11:03 PM EDT
private void button1_Click(object sender, EventArgs e)
{
double a, b,c;
a = Convert.ToDouble(textBox1.Text );
b = Convert.ToDouble(textBox2.Text);
c = a + b;
label1.Text = c.ToString();
}
JAYRAMRank #7,836 · 233 reputationPosted Apr 17, 2014, 1:27 AM EDT
int b = Convert.ToInt32(Txt_2.Text);
int c = a + b;
Ans.Text = c.ToString();
above code write in pageload ...
i shows error
AshishRank #8,652 · 218 reputationPosted Apr 17, 2014, 1:31 AM EDT
Srikanth Reddy142 reputationPosted Apr 17, 2014, 2:22 AM EDT
Shweta LodhaRank #31 · 39.8K reputationPosted Apr 17, 2014, 2:30 AM EDT