if i have `<asp:UpdatePanel ...` than there is no alert message poup

1.4k Views Asked by At

i just noticed that if i remove the <asp:UpdatePanel ... then i get the alert message

how to alert a message from code-behind and i have tried number of ways but i never get alert message, below is my code:

protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
  if (e.CommandName == CRUID.Delete.ToString())
  {

  ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Deleted successfully!');", true);

or

// Define the name and type of the client scripts on the page.
         String csname1 = "PopupScript";
         Type cstype = this.GetType();

         // Get a ClientScriptManager reference from the Page class.
         ClientScriptManager cs = Page.ClientScript;

         // Check to see if the startup script is already registered.
         if (!cs.IsStartupScriptRegistered(cstype, csname1))
         {
             StringBuilder cstext1 = new StringBuilder();
             cstext1.Append("<script type=text/javascript> alert('Hello World!') </");
             cstext1.Append("script>");

             cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
         }
   }
}

protected override void Page_Load(object sender, EventArgs e)
{
   gv.DataSourceID = "gvDataSource";
}

ps: iam using objectdatasource to bind my gridview control

1

There are 1 best solutions below

0
On BEST ANSWER

try change:

ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Deleted successfully!');", true);