Description

There are two ways to redirect clients to a new page. 1) add javascript to the callback response to change the window location, or 2) use the ASP.NET Response.Redirect() method. If you use Response.Redirect(), Anthem will catch it and convert it into javascript that changes the window location.

Example


Steps

  1. Add an anthem:Button control to the page with an event handler specified in its OnClick attribute:

    <anthem:Button id="button1" runat="server" 
        Text="Redirect Me!" 
        OnClick="button1_Click" />
    <anthem:Button id="button2" runat="server" 
        Text="Redirect Me!" 
        OnClick="button2_Click" />
  2. Implement the event handler so that it calls Anthem.Manager.AddScriptForClientSideEval() or Response.Redirect():

    void button1_Click(object sender, EventArgs e) 
    { 
        Anthem.Manager.AddScriptForClientSideEval("alert('Bye!')");
        Anthem.Manager.AddScriptForClientSideEval(
            "window.location = 'http://anthem-dot-net.sourceforge.net/';"
        );
    }
    
    void button2_Click(object sender, EventArgs e)
    { 
        Response.Redirect("http://anthem-dot-net.sourceforge.net");
    }

Remarks

You can add any JavaScript you want to via the AddScriptForClientSideEval method. Each script gets evaluated in the order it was added on the server once it gets returned to the client.