Hi...i want use alert message in code behind....but i dont to fire this message on button click ...i want that this alert message display base on some if condition....can any one help me with example??

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),"err_msg", "alert('Your Message')');",true);

hi..

try this..

if condition1 then
    ClientScript.RegisterStartupScript(Me.GetType(), "ErrorMessage", "<script type='text/javascript'>alert('ERROR!');</script>'")
    exit sub

elseif condition2 then
    ClientScript.RegisterStartupScript(Me.GetType(), "ErrorMessage", "<script type='text/javascript'>alert('ERROR2!');</script>'")
    exit sub

else
    ClientScript.RegisterStartupScript(Me.GetType(), "Confirm", "<script type='text/javascript'>alert('Saved!');</script>'")

end if
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.