hi tried your code and changed simple small things and i tested the results
try this
protected void Page_Load(object sender, EventArgs e)
{
string msgBoxVal = string.Empty;
if (Session["LabelDetails"] != null)
{
msgBoxVal = Convert.ToString(Session["LabelDetails"]);
Session.Remove("LabelDetails");
}
if (msgBoxVal != "")
{
MessageBox("Test1");
MessageBox("The shipping label is successfully deleted! Deleted label details: " + msgBoxVal);
MessageBox("Test2");
}
}
private void MessageBox(string msg)
{
Page.Controls.Add(new LiteralControl("<script type=\"text/javascript\"> window.alert('" + msg.Replace("'", "\\'") + "')</script>"));
}