New to Asp.Net Need connecting string and Add 2 values

Mohamed Rafi N 106 Reputation points
2022-03-15T04:52:34.023+00:00

Sir,

I am new to asp.net i have installed visual studio community 2022 i want to know how to add 2 values and display the output, i need step procedure. please guide me

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,301 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 26,121 Reputation points Microsoft Vendor
    2022-03-16T09:30:09.67+00:00

    Hi @Mohamed Rafi N ,
    The type of textBox1.Text is string and cannot be directly equal to int type.
    If you use addition, you need to use the Convert.ToInt32 method to convert the specified value to a 32-bit signed integer.
    If you have other questions, please click comment.
    183579-1.jpg
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Lan Huang-MSFT 26,121 Reputation points Microsoft Vendor
    2022-03-15T06:06:31.33+00:00

    Hi @Mohamed Rafi N ,
    What specific project do you want to use, asp.net webform?
    Are you trying to add two values to the database?
    You are a newbie, I suggest you to check Microsoft's related documentation, there are specific steps on it.
    https://learn.microsoft.com/en-us/aspnet/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Sreeju Nair 11,621 Reputation points
    2022-03-15T06:09:05.133+00:00

    Since you are starting new, I recommend you to go through ASP.Net Razor Pages along with Entity Framework Core to start building.

    https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/intro?view=aspnetcore-6.0&tabs=visual-studio

    The following link gives you a walkthrough for the CRUD operations (Create, Read, UPdate and Delete) .

    https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/crud?view=aspnetcore-6.0

    Hope this helps

    0 comments No comments

  3. Mohamed Rafi N 106 Reputation points
    2022-03-16T07:45:37.957+00:00

    what is the error in this code?

    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace FirstConsoleApp
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    int input1 = Convert.ToInt32(textBox1.Text);
    int input2 = Convert.ToInt32(textBox2.Text);
    int result = input1 + input2;
    MessageBox.Show("Addition result = " + result.ToString());
    }
    catch (Exception ex)
    {

            }
    
            //int a, b, c;
           // a = textBox1.Text;
           // b = textBox2.Text;
          // c = a + b;
            //textBox5.Text = c;
        }
    }
    

    }


  4. Mohamed Rafi N 106 Reputation points
    2022-03-16T09:09:26.28+00:00

    {
    int a, b, c;
    a = textBox1.Text;
    b = textBox2.Text;
    c = a + b;
    textBox3.Text = c;
    }

    what is the error in this code sir?