0

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.

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by plazmo
0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.