First Add Your link Button and Div message in .ASPX
<asp:LinkButton ID="ancDelete" CommandName="delete" OnCommand="delete_EventCategories" runat="server">Delete </asp:LinkButton>
<div id="divMessage" runat="server" class="grid_7 alpha" style="display: none;">
<asp:Literal runat="server" ID="ltlMessage" Text="test"></asp:Literal>
</div>
Then write a Show method.
public static void ShowMessage(string _class, string msg, System.Web.UI.HtmlControls.HtmlGenericControl divMessage, Literal ltlMessage)
{
divMessage.Style.Add("display", "block");
divMessage.Attributes.Add("class", _class);
ltlMessage.Text = msg;
}
And finally Event Hadelers.
protected void delete_EventCategories(object Sender, CommandEventArgs e)
{
if (e.CommandName == "delete")
{
try
{
ShowMessage("alert alert-success", " Successfully!",divMessage, ltlMessage);
}
catch (Exception ex)
{
ShowMessage("alert alert-error", ex.InnerException.Message, divMessage,ltlMessage);
}
}
}