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. how can i show a message box??

how can i show a message box??

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-net
9 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.
  • R Offline
    R Offline
    regin
    wrote on last edited by
    #1

    :confused:how can i show a message box??in asp.net using c#. i have to show one message when a specific condn satisfies..;P

    K A E 3 Replies Last reply
    0
    • R regin

      :confused:how can i show a message box??in asp.net using c#. i have to show one message when a specific condn satisfies..;P

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      If you are doing a post back you can use code like this: NOTE you need: using System.Text; private void ShowMessageBox(string aMessage) { aMessage = aMessage.Replace(vbCrLf, "\\n").Replace("\"", "'"); StringBuilder myScript = new StringBuilder(); myScript.Append(""); myScript.Append(Environment.NewLine); myScript.Append("alert(\"").Append(aMessage).Append("\");"); myScript.Append(Environment.NewLine); myScript.Append(""); Page.RegisterStartupScript("TagMessage", myScript.ToString()); } NOTE in .net 2.0 the call to registerstartupscript has changed. If you are not doing a post back you have to use javascript. Hope that helps. Ben

      R 1 Reply Last reply
      0
      • R regin

        :confused:how can i show a message box??in asp.net using c#. i have to show one message when a specific condn satisfies..;P

        A Offline
        A Offline
        ajay58886
        wrote on last edited by
        #3

        hi.......... ex:- if(TextBox1.Text!=null && TextBox1.Text!="") MsgBox1.alert("Please input something in the text box."); else MsgBox1.confirm("Hello "+ TextBox1.Text + "! do you want to continue?", "hid_f"); hope your prob. slove........

        Imagine the I.T

        1 Reply Last reply
        0
        • K kubben

          If you are doing a post back you can use code like this: NOTE you need: using System.Text; private void ShowMessageBox(string aMessage) { aMessage = aMessage.Replace(vbCrLf, "\\n").Replace("\"", "'"); StringBuilder myScript = new StringBuilder(); myScript.Append(""); myScript.Append(Environment.NewLine); myScript.Append("alert(\"").Append(aMessage).Append("\");"); myScript.Append(Environment.NewLine); myScript.Append(""); Page.RegisterStartupScript("TagMessage", myScript.ToString()); } NOTE in .net 2.0 the call to registerstartupscript has changed. If you are not doing a post back you have to use javascript. Hope that helps. Ben

          R Offline
          R Offline
          regin
          wrote on last edited by
          #4

          im getting an error on tis code

          K 1 Reply Last reply
          0
          • R regin

            im getting an error on tis code

            K Offline
            K Offline
            kubben
            wrote on last edited by
            #5

            Are you using .net 2.0? What is the error? Ben

            R 1 Reply Last reply
            0
            • K kubben

              Are you using .net 2.0? What is the error? Ben

              R Offline
              R Offline
              regin
              wrote on last edited by
              #6

              yes im using 2.0..n wats this vbCrLf,and the Page.RegisterStartupScript error...im using c#

              K 1 Reply Last reply
              0
              • R regin

                :confused:how can i show a message box??in asp.net using c#. i have to show one message when a specific condn satisfies..;P

                E Offline
                E Offline
                enjoycrack
                wrote on last edited by
                #7

                hi there: you can take a look at this article asp.net message box << >>

                8x Solutions Ltd

                R 1 Reply Last reply
                0
                • R regin

                  yes im using 2.0..n wats this vbCrLf,and the Page.RegisterStartupScript error...im using c#

                  K Offline
                  K Offline
                  kubben
                  wrote on last edited by
                  #8

                  ah, replace that with Environment.NewLine. Sorry about that. Ben

                  1 Reply Last reply
                  0
                  • E enjoycrack

                    hi there: you can take a look at this article asp.net message box << >>

                    8x Solutions Ltd

                    R Offline
                    R Offline
                    regin
                    wrote on last edited by
                    #9

                    thanks its working....

                    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