?
Solved

problem window alert java c# web form

Posted on 2007-10-09
2
Medium Priority
?
1,421 Views
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>");
                Response.Redirect("Menu.aspx");
            }
        }
    }
0
Comment
Question by:tenriquez39
2 Comments
 
LVL 4

Accepted Solution

by:
iuconStefan earned 200 total points
ID: 20042010
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>");

0
 

Author Comment

by:tenriquez39
ID: 20042418
wonderfull you are great thanks allot
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

829 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