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. MessageBox

MessageBox

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmindebuggingjsonhelp
12 Posts 3 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.
  • K kubben

    It appears that you are missing and '=' between language and javascript. Instead of using Response.Write perhaps you should register a startup script.

    private void ShowDialog(string p_msg)
    {
    Type cstype = this.GetType();
    StringBuilder tmpSB = new StringBuilder();
    tmpSB.Append("");

    tmpSB.Append("alert('" + p_msg + "')");
    tmpSB.Append("");
    ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString());
    }

    Hope that helps. Ben

    M Offline
    M Offline
    M_Menon
    wrote on last edited by
    #3

    Hi Ben Thanks for the Reply, here is the code protected void cancelRec(object sender, EventArgs e) { ShowDialog("test"); } private void ShowDialog(string p_msg) { Type cstype = this.GetType(); StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); tmpSB.Append("alert('" + p_msg + "')"); tmpSB.Append(""); ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString()); } But its not working. Nor throwing any error. Any idea? Thanks Cheers Menon

    K S 2 Replies Last reply
    0
    • M M_Menon

      Hi Ben Thanks for the Reply, here is the code protected void cancelRec(object sender, EventArgs e) { ShowDialog("test"); } private void ShowDialog(string p_msg) { Type cstype = this.GetType(); StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); tmpSB.Append("alert('" + p_msg + "')"); tmpSB.Append(""); ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString()); } But its not working. Nor throwing any error. Any idea? Thanks Cheers Menon

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

      The message box will only pop up after the page posts back. Is your CancelRec getting called? What are you really trying to do? I am guessing that since the method is called cancel rec you perhaps want to prompt the user before they cancel? If that is the case you want to do something complete different with javascript. If that is the case let me know and I can show you the code. Ben

      M 1 Reply Last reply
      0
      • M M_Menon

        Hi Ben Thanks for the Reply, here is the code protected void cancelRec(object sender, EventArgs e) { ShowDialog("test"); } private void ShowDialog(string p_msg) { Type cstype = this.GetType(); StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); tmpSB.Append("alert('" + p_msg + "')"); tmpSB.Append(""); ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString()); } But its not working. Nor throwing any error. Any idea? Thanks Cheers Menon

        S Offline
        S Offline
        Sandeep Kumar
        wrote on last edited by
        #5

        Hey mady1380 could you please tel me the scenario so that we can help you better.

        Regards, Sandeep Kumar.V

        M 1 Reply Last reply
        0
        • K kubben

          The message box will only pop up after the page posts back. Is your CancelRec getting called? What are you really trying to do? I am guessing that since the method is called cancel rec you perhaps want to prompt the user before they cancel? If that is the case you want to do something complete different with javascript. If that is the case let me know and I can show you the code. Ben

          M Offline
          M Offline
          M_Menon
          wrote on last edited by
          #6

          Hi Ben I am sorry about the code. Actually i put the code in the CancelButton just to test. I want it on the click of Savebutton. I am creating textboxes dynamically. And I want to throw Error via Messagebox if the Textbox is empty. Thats it. It still appreciate your help still.. Thanks Cheers Menon

          K 1 Reply Last reply
          0
          • M M_Menon

            Hi Ben I am sorry about the code. Actually i put the code in the CancelButton just to test. I want it on the click of Savebutton. I am creating textboxes dynamically. And I want to throw Error via Messagebox if the Textbox is empty. Thats it. It still appreciate your help still.. Thanks Cheers Menon

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

            Are you using .net 2.0? The code I posted was for .net 2.0 it is slightly different for .net 1.0 or 1.1. If you are using .net 2.0 then it should work. You could always do a more pure javascript solution. Ben

            M 1 Reply Last reply
            0
            • S Sandeep Kumar

              Hey mady1380 could you please tel me the scenario so that we can help you better.

              Regards, Sandeep Kumar.V

              M Offline
              M Offline
              M_Menon
              wrote on last edited by
              #8

              Hi Sandeep I am Creating Textbox dynamically. I am making a check if the Textbox is null I want to Throw an Error via MessageBox. I dont want it Onclick of button. I want to display the MessageBox on particular condition. Eg: if(txtName.Text=="") ShowDialog("Name Cannot Be Empty");//MESSAGE BOX I hope its clear. Thanks Cheers Menon

              S 1 Reply Last reply
              0
              • K kubben

                Are you using .net 2.0? The code I posted was for .net 2.0 it is slightly different for .net 1.0 or 1.1. If you are using .net 2.0 then it should work. You could always do a more pure javascript solution. Ben

                M Offline
                M Offline
                M_Menon
                wrote on last edited by
                #9

                Hi Ben Yes i am using .NET 2.0 Cheers Menon

                K 1 Reply Last reply
                0
                • M M_Menon

                  Hi Ben Yes i am using .NET 2.0 Cheers Menon

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

                  Well then if you can verify in debug mode that the code behind is getting hit. If that is happening when that page comes back up, the question would be do you have pop up blockers that might be blocking the message box? You can always check the source of the page with View source. You should see the javascript toward the bottom of the page. At this point I would be guess that it is either a pop up blocker or the code behind isn't getting hit or something like that. Ben

                  1 Reply Last reply
                  0
                  • M M_Menon

                    Hi Sandeep I am Creating Textbox dynamically. I am making a check if the Textbox is null I want to Throw an Error via MessageBox. I dont want it Onclick of button. I want to display the MessageBox on particular condition. Eg: if(txtName.Text=="") ShowDialog("Name Cannot Be Empty");//MESSAGE BOX I hope its clear. Thanks Cheers Menon

                    S Offline
                    S Offline
                    Sandeep Kumar
                    wrote on last edited by
                    #11

                    mady1380 wrote:

                    I want to display the MessageBox on particular condition.

                    could you please sepicify a condition?? like when you want to test textbox is null or not.....

                    Regards, Sandeep Kumar.V

                    M 1 Reply Last reply
                    0
                    • S Sandeep Kumar

                      mady1380 wrote:

                      I want to display the MessageBox on particular condition.

                      could you please sepicify a condition?? like when you want to test textbox is null or not.....

                      Regards, Sandeep Kumar.V

                      M Offline
                      M Offline
                      M_Menon
                      wrote on last edited by
                      #12

                      I want to make this Check about the TextBox on the Click Event of my OK button. Cheers Menon

                      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