Scorpio
Scorpio

Reputation: 1171

alert box from asp.net 3.5 Code-Behind

protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
{           
    if (ddlLanguage.SelectedValue=="es-ES")
    {
        Page page = HttpContext.Current.CurrentHandler as Page;

        page.ClientScript.RegisterStartupScript(typeof(Page), "Script", "<script language='javascript'>alert('All content may not be in Spanish. Do you want to continue...');</script>");            
    }
}

All I want to do is display a simple alert box but all in vain...nothing pops-up. need some ayudar.

Upvotes: 1

Views: 4927

Answers (3)

Krishna Tiwari
Krishna Tiwari

Reputation: 41

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showalert","Alert Message", true);

This works for me without Postback try this

Upvotes: 0

Agent007
Agent007

Reputation: 2750

You need to verify if the startup script is not registered already. Check out this post.

Also you can build your custom MessageBox in ASP.NET. Check out this one.

Upvotes: 2

Waqar Janjua
Waqar Janjua

Reputation: 6123

You can also achieve in this way

protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
{           
  if (ddlLanguage.SelectedValue=="es-ES")
   {         
      Response.Write("<script>alert('All content may not be in Spanish. Do you want to continue...');</script>");            
   }
}

Upvotes: 2

Related Questions