0

m using java srcipt messagebox..

private void MessageBox(string msg)
    {
        System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label();
        lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "');</script>";
        //lbl.Text = "<script>window.alert('" + msg + "');</script>";
        Page.Controls.Add(lbl);
    }

now i want to reload my page..but if i write response.redirect my messagebox is not display....i write this function in code behind and call it when i need to display messagebox...so, how can i reload my page???????

1
  • don't use Labelfor that, use <asp:Literal> Web Control, Label Control always escapes stuff... Commented Apr 20, 2011 at 9:43

1 Answer 1

3

Like this

lbl.Text = "<script>window.alert('" + msg + "');window.location.replace('yourotherpage.aspx')</script>";

But please don't forget to properly escape the quotes in your "msg" text. Otherwise you may get a broken script code.

Sign up to request clarification or add additional context in comments.

3 Comments

i use quotoes but it cant work properly it gives error ; expected
it's missing a ; after the replace method: window.location.replace('yourotherpage.aspx');
@ jaymz :i can done that but it still gives error ; expected

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.