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

RadWindowManager.RadAlert not working

2 Answers 596 Views
Window
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 11 Jul 2011, 04:05 AM
I am calling the RadAlert function in my code behind when a user clicks on the "Login" button. This is a very simple page with very simple functionality and I am following the examples to a tee, but still nothing. I am thinking it is because I am calling the function within a catch block when the login is unsuccessful, meaning that I am trying to display the window when the execution isn't finished. Can someone help me with this as I am stumped as to how best to proceed? My HTML and C# code is below:

<form runat="server" id="frmLogin">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadWindowManager ID="LoginWindowManager" runat="server" EnableShadow="true" Skin="Telerik" />
    <div class="loginDiv">
        <asp:Image ID="ivxLogo" AlternateText="iVidix Logo" ImageUrl="./img/ividix_logo.jpg" Height="150px"
                    Width="110px" runat="server" />
        <p>Welcome to the Instructional Video Exchange. Please login to access your videos.</p>
        <div align="center">
            <table border="0" cellpadding="0" cellspacing="10">
                <tr>
                    <td>UserName:</td>
                    <td>
                        <telerik:RadTextBox ID="txtUserName" runat="server" Width="150px" TabIndex="0" Skin="Vista" />
                    </td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td>
                        <telerik:RadTextBox ID="txtPassword" runat="server" Width="150px" TabIndex="1"
                            TextMode="Password" Skin="Vista">
                        </telerik:RadTextBox></td>
                </tr>
                <tr>
                    <td>Institution:</td>
                    <td>
                        <telerik:RadComboBox ID="ddlInstitutions" runat="server" DataSourceID="srcInstitutions"
                            DataTextField="Name" DataValueField="InstID" TabIndex="2" Skin="Vista" AllowCustomText="True">
                        </telerik:RadComboBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right"><asp:Button ID="btnSubmit" runat="server"
                            Text="Login" onclick="btnSubmit_Click" TabIndex="3"/></td>
                </tr>
            </table>
        </div>
    </div>
</form>


try
{
   String encryptPwd = CryptoHelper.Encrypt(password);
    //log.Debug("Encrypted version of the password: " + password + " is " + encryptPwd);
    userSession = SessionManager.CreateSession(userName, encryptPwd, instID);
}
catch (IvidixException ex)
{
    String ErrorMessage = "UserName and/or Password in combination with the Institution were not valid. Please try again.\n";
    ErrorMessage = ErrorMessage + "Specifically, " + (String) ex.LocalMessages[0] + "\n";
    ErrorMessage = ErrorMessage + "Please contact Ividix Support if you feel that this error is incorrect.";
 
    log.Error("UserDetail Session was not created properly and therefore not stored within the HttpSession.");
    log.Debug("End btnSubmit_Click");
 
    LoginWindowManager.RadAlert(ErrorMessage, 350, 200, "Error", "");
 
    return;
}

2 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 11 Jul 2011, 10:21 AM
Hi Brian,

 I examined your code and I noticed that you have an unescaped "\" sign in it - please, note, that this is general JavaScript knowledge and it will break any other javascript, not only radalert (the server RadAlert method is actually a server wrapper for a js radalert method).

I assume that you meant to set a new line by using "\n" - if  so, please, note, that the message can also parse HTML and "\n" will not produce a new line even if it did not broke the js but you have escaped it. To achieve what you need, please, use the <br/> tag as shown below:


String ErrorMessage = "UserName and/or Password in combination with the Institution were not valid. Please try again.<br/>";
  
    ErrorMessage = ErrorMessage + "Specifically, " + (String) ex.LocalMessages[0] + "<br/>";
  
    ErrorMessage = ErrorMessage + "Please contact Ividix Support if you feel that this error is incorrect.";

Please, test my suggestion and let me know how it goes.

Best wishes,
Svetlina
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Brian
Top achievements
Rank 1
answered on 11 Jul 2011, 05:04 PM
Svetlina,

You were completely dead on. I did not realize that the server-side call was just a wrapper for the client-side function. That is not very clear from the documentation.

That being said, I didn't even think about the message that I am displaying because I wrote that code so long ago. As soon as I changed it to use break tags, everything worked just fine. Thank you very much for the help.

Brian
Tags
Window
Asked by
Brian
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Brian
Top achievements
Rank 1
Share this question
or