problem window alert java c# web form

Posted on 2007-10-09
Last Modified: 2013-12-17
i have a code in .net c# . it is to show a message box type, and redirect navegation to other web form (my project is with web forms) i have next code, but it don't show the message . It go directly to menu.asxc form i test...if i commente second line (response.redirect) the message is correct, and show me in the scrren but if ...two lines active don't show me teh message:  her the code:

    protected void Page_Load(object sender, EventArgs e)
        string VUsus,x;
        VUsus = Session["Usuario"].ToString();
        x = ClaseValAcc.myGlobalFunction("CatAplis", VUsus);
        if (!Page.IsPostBack)
            if (x == "")
                Response.Write("<script>window.alert('Acceso no permitido')</script>");
Question by:tenriquez39
    LVL 4

    Accepted Solution

    this is because a call to Response.Redirect will simply send a 302 Code to the Browser (page moved). The page body will not be rendered, the browser requests the next page (menu.aspx).

    You could redirect the user via javascript to get your message box visible:

     Response.Write("<script langauge=\"javascript\">window.alert('Acceso no permitido')</script>");
     Response.Write("<script langauge=\"javascript\">document.location.replace('Menu.aspx')</script>");


    Author Comment

    wonderfull you are great thanks allot

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now