Hi nauna,
Yes you can.
Follow the below steps.
1. Create a class file and write the below code.
public class MessagePopup
{
private System.Web.UI.Page page;
public MessagePopup(System.Web.UI.Page pages)
{
page = pages;
}
public void ShowMessage(string Message, string messageType)
{
if (messageType.ToLower() == "success")
{
messageType = "Success";
}
else if (messageType.ToLower() == "error")
{
messageType = "Error";
}
else if (messageType.ToLower() == "info")
{
messageType = "Info";
}
else if (messageType.ToLower() == "warning")
{
messageType = "Warning";
}
System.Web.UI.ScriptManager.RegisterStartupScript(page, this.GetType(), System.Guid.NewGuid().ToString(), "ShowMessage('" + Message + "','" + messageType + "');", true);
}
}
2. Call the method using the below code in the page where you want to call.
MessagePopup messagePopup = new MessagePopup(this.Page);
messagePopup.ShowMessage("Record submitted successfully", "Success");