Saturday, 13 September 2014

Error Handling in Windows Application Using C#.Net

9/13/2014 - By Pranav Singh 0

In this article I will show you how you can handle error in windows application using c#.net. This will help your user to enter correct data.


So for this article first we will create a new windows application and in this form  we will add a button and a text box and a button control.



Now go to code end and add the below code to validate the textbox value.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //Error handeling in windows app;lkication using c#.net
        private void button1_Click(object sender, EventArgs e)
        {
            string dataMesage = Validationmessage();
            if (dataMesage == "")
            {
                MessageBox.Show("Your name is : " + txtname.Text);
            }
            else
            {
                MessageBox.Show(dataMesage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public string Validationmessage()
        {
            string dataMesssage = "";
            if (txtname.Text == "")
            {
                dataMesssage = "Please enter name.";
            }
            return dataMesssage;
        }
    }
}

So here is the output.



DOWNLOAD

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top