Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Showing error message

Showing error message

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasejavaasp-netlinq
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    future3839
    wrote on last edited by
    #1

    Hi, I am developing a simple web application in ASP.net. I would like to know in database connection if I face with error how I should show it. do I have to use java script? because unlike desktop application can't use message box.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data.SqlClient;
    using System.Data;
    using System.Data.Sql;
    using System.Configuration;

    namespace Test.DataAccessLayer
    {
    public class PersonDataAccess
    {

        SqlConnection Conn = new                             SqlConnection(ConfigurationManager.ConnectionStrings\["HostelConnectionString"\].ConnectionString);
    
        public void insert()
        {
            try
            {
                Conn.Open();
            }
            catch (Exception ex)
            {                
    

    ????????????????????????????????????????????????????????????????????????????
    }
    }
    }
    }

    B R B 3 Replies Last reply
    0
    • F future3839

      Hi, I am developing a simple web application in ASP.net. I would like to know in database connection if I face with error how I should show it. do I have to use java script? because unlike desktop application can't use message box.

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Data.SqlClient;
      using System.Data;
      using System.Data.Sql;
      using System.Configuration;

      namespace Test.DataAccessLayer
      {
      public class PersonDataAccess
      {

          SqlConnection Conn = new                             SqlConnection(ConfigurationManager.ConnectionStrings\["HostelConnectionString"\].ConnectionString);
      
          public void insert()
          {
              try
              {
                  Conn.Open();
              }
              catch (Exception ex)
              {                
      

      ????????????????????????????????????????????????????????????????????????????
      }
      }
      }
      }

      B Offline
      B Offline
      benams
      wrote on last edited by
      #2

      you don't have to use javascript, you can catch the exception and assign ex.message to a label's text. if you still want to use a message box, you do have to use javascript(you can download a exist class)

      1 Reply Last reply
      0
      • F future3839

        Hi, I am developing a simple web application in ASP.net. I would like to know in database connection if I face with error how I should show it. do I have to use java script? because unlike desktop application can't use message box.

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Data.SqlClient;
        using System.Data;
        using System.Data.Sql;
        using System.Configuration;

        namespace Test.DataAccessLayer
        {
        public class PersonDataAccess
        {

            SqlConnection Conn = new                             SqlConnection(ConfigurationManager.ConnectionStrings\["HostelConnectionString"\].ConnectionString);
        
            public void insert()
            {
                try
                {
                    Conn.Open();
                }
                catch (Exception ex)
                {                
        

        ????????????????????????????????????????????????????????????????????????????
        }
        }
        }
        }

        R Offline
        R Offline
        RaviRanjanKr
        wrote on last edited by
        #3

        you can show your message, by using Java script alert Message as

        Response.Write("<script>alert('Your Message')</script>");

        or you can also use custom error concept to show your message while a error generate follow link Custom Errors in ASP.NET[^]

        1 Reply Last reply
        0
        • F future3839

          Hi, I am developing a simple web application in ASP.net. I would like to know in database connection if I face with error how I should show it. do I have to use java script? because unlike desktop application can't use message box.

          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Web;
          using System.Data.SqlClient;
          using System.Data;
          using System.Data.Sql;
          using System.Configuration;

          namespace Test.DataAccessLayer
          {
          public class PersonDataAccess
          {

              SqlConnection Conn = new                             SqlConnection(ConfigurationManager.ConnectionStrings\["HostelConnectionString"\].ConnectionString);
          
              public void insert()
              {
                  try
                  {
                      Conn.Open();
                  }
                  catch (Exception ex)
                  {                
          

          ????????????????????????????????????????????????????????????????????????????
          }
          }
          }
          }

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          It is not a good practice, to show exception errors in javascript alert. Better , if you find any exception , show in that page or redirect to some other error page

          Cheers!! Brij Visit my Blog: http://brijbhushan.net
          Check my latest Article :ViewState - Various ways to reduce performance overhead

          R 1 Reply Last reply
          0
          • B Brij

            It is not a good practice, to show exception errors in javascript alert. Better , if you find any exception , show in that page or redirect to some other error page

            Cheers!! Brij Visit my Blog: http://brijbhushan.net
            Check my latest Article :ViewState - Various ways to reduce performance overhead

            R Offline
            R Offline
            RaviRanjanKr
            wrote on last edited by
            #5

            Brij wrote:

            Better , if you find any exception , show in that page or redirect to some other error page

            Ya i knew it, that's why i have already describe or refer a link about custom error which works as you say.:suss:

            B 1 Reply Last reply
            0
            • R RaviRanjanKr

              Brij wrote:

              Better , if you find any exception , show in that page or redirect to some other error page

              Ya i knew it, that's why i have already describe or refer a link about custom error which works as you say.:suss:

              B Offline
              B Offline
              Brij
              wrote on last edited by
              #6

              RaviRanjankr wrote:

              Ya i knew it, that's why i have already describe or refer a link about custom error which works as you say

              Obiously, you must be knowing. I just suggested , not to use JS alert.

              Cheers!! Brij Visit my Blog: http://brijbhushan.net
              Check my latest Article :ViewState - Various ways to reduce performance overhead

              R 1 Reply Last reply
              0
              • B Brij

                RaviRanjankr wrote:

                Ya i knew it, that's why i have already describe or refer a link about custom error which works as you say

                Obiously, you must be knowing. I just suggested , not to use JS alert.

                Cheers!! Brij Visit my Blog: http://brijbhushan.net
                Check my latest Article :ViewState - Various ways to reduce performance overhead

                R Offline
                R Offline
                RaviRanjanKr
                wrote on last edited by
                #7

                Brij wrote:

                Obiously, you must be knowing. I just suggested , not to use JS alert.

                whatever, thanks for your guidance or suggestion. ;) ;)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups