Im using VS 2005 for web application.Im using message boxes but they are not working.i dont know what's the problem with my code.

if (drff.Read())
            {
                Button_Assign.Attributes.Add("onclick", "javscript:alert('Data saved successfully.')");
               
            }
            /*else
            {
                //Button_Assign.Attributes.Add("onclick", "javscript:alert('Data not saved.')");
             
            }

my data is saved successfully but im not getting the alert.same is the case with cancel/exit button.Please help me.

Recommended Answers

All 3 Replies

you mispelt javascript

javscript

javascript

its still not working.
the values are updated in the database but alert is not displyed.

what you have will not work because you are adding the onclick event after the button was already clicked. so after the page postsback you should get that alert when you press the button using your code.

use this.

if (drff.Read())
            {
                ClientScript.RegisterStartupScript(typeof(string), "success", "alert('Data saved successfully.');", true);   
            }
            else
            {
                ClientScript.RegisterStartupScript(typeof(string), "fail", "alert('Data not saved.');", true);
            }

this adds the alert to the page load, which is the place you want to add it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.