This is a migrated thread and some comments may be shown as answers.

radAlert x Response.redirect()

1 Answer 60 Views
Window
This is a migrated thread and some comments may be shown as answers.
cayo fontana
Top achievements
Rank 1
cayo fontana asked on 10 Jun 2010, 02:43 AM
Hi there,

I have, in a telerik web application, one button making logon of the users. Look:

 

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
<ContentTemplate>

 

<asp:Button ID="btnEntrar" runat="server" Text="Entrar" onmouseover="this.style.cursor='hand'"

 

OnClick="btnEntrar_Click" />

 

</ContentTemplate>

 

</asp:UpdatePanel>


In server side, i have 2 states:

if user was authenticated, response.redirect("page.aspx"),
else app sends radalert.
Look:

 

protected

 

 

void btnEntrar_Click(object sender, EventArgs e)  

 

 

{

 

 

 

if ((this.txtLogin.Text == "cayo") && (this.txtSenha.Text == "123"))

{

Response.Redirect(

 

"Principal.aspx"); 

 

 

}

 

 

 

else

 

{

 

 

 

ScriptManager.RegisterStartupScript(this, this.GetType(), "radalerts", "radalert('Login ou senha <b>inválidos</b>! Favor verificar.', 330, 100);", true);

}

 

 

}

 

 

 

If i dont set RadScriptManager1.RegisterPostBackControl(this.btnEntrar); in Page_Load, radalert is work and redirect fails, else, redirect works and radalert fails.

whats to happen?

 

 

1 Answer, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 15 Jun 2010, 08:53 AM
Hi Cayo,

When you call a control that is built upon the MS AJAX library (RadWindwowManager for example) you need to make sure that the library is loaded before calling the methods of the controls. This is why, I recommend you to call the radalert (which is a part of RadWindowManager) using this code:
protected void btnEntrar_Click(object sender, EventArgs e)
{
    if (this.TextBox1.Text == "cayo")
    {
        Response.Redirect("Principal.aspx");
    }
    else
    {
        string script = @"function f()
                        {
                            Sys.Application.remove_load(f);
                            radalert('Login ou senha <b>inválidos</b>! Favor verificar.', 330, 100);
                        }
                        Sys.Application.add_load(f); ";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "radalerts", script, true);
    }
}

I hope this helps.

Sincerely yours,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Window
Asked by
cayo fontana
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or