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

RadAlert not displaying

3 Answers 271 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 16 Oct 2008, 03:20 PM
I am having trouble getting a RadAlert mesaage to display after a postback button click.  I have tried the solutions shown in the KB article on RadAlert, but cannot get it to work.

I have an input form sshown below, and in the Submit_Click routine I do data validation.  On a validation error I have the radAlert code:

protected

 

void Submit_Click(object sender, EventArgs e){
    ...validation code....
    if (error)
    {
    message = "Required information missing. Please fill in all required information.";
    string scriptstring = "radalert('" + message + "', 330, 180, 'CPR+ Web Portal Alert');";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "radalert", scriptstring, true);
    }

But this does not result in any alert message display.  Why?

My aspx page:

 

<%@ Page Language="C#" MasterPageFile="~/Master/SiteTemplate.master" AutoEventWireup="true"
CodeFile="createuserform.aspx.cs" Inherits="Admin_createuserform" Title="Create User Account" %>

<%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>
<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %>
<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %>
<%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="radI" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphWebData" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <radW:RadWindowManager ID="messages" runat="server" Skin="WebBlue">
    </radW:RadWindowManager>
    <radA:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%" LoadingPanelID="AjaxLoadingPanel1">
        <div class="info-row gradient">
            <h1 class="primary-font-color row-heading">ACCOUNT INFORMATION:</h1>
                <div class='label' style="width: 170px">
                    <asp:Label ID="lblUsername" runat="server" Text="Username*:"></asp:Label>
                </div>
                <div class='field'>
                    <radI:RadTextBox ID="txtUsername" runat="server" Skin="Monochrome"
                        Width="159px" MaxLength="100">
                    </radI:RadTextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                        ControlToValidate="txtUsername" Display="Dynamic"
                        ErrorMessage="Username is required!"></asp:RequiredFieldValidator>
                </div>
                <div id='password'>
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblPassword" runat="server" Text="Password*:"></asp:Label>
                    </div>
                    <div class='field' style="vertical-align: middle;">
                        <radI:RadTextBox ID="txtPassword" runat="server" TextMode="Password" Skin="Monochrome"
                            SelectionOnFocus="SelectAll" Width="159px" MaxLength="50">
                        </radI:RadTextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                            ControlToValidate="txtPassword" Display="Dynamic"
                            ErrorMessage="Password is required!"></asp:RequiredFieldValidator>
                    </div>
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblVerifyPwd" runat="server" Text="Verify Password*:"></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadTextBox ID="txtVerifyPwd" runat="server" TextMode="Password" Skin="Monochrome"
                            SelectionOnFocus="SelectAll" Width="159px" MaxLength="50">
                        </radI:RadTextBox>
                        <asp:CompareValidator ID="ComparePassword" runat="server" ErrorMessage="Passwords do not match!"
                            ControlToValidate="txtVerifyPwd" ControlToCompare="txtPassword" SetFocusOnError="true" Font-Size="xx-small" Font-Bold="True"></asp:CompareValidator>
                    </div>
                </div>
        </div>
        <div class="info-row ">
                <div id='email'>
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblEmail" runat="server" Text="E-mail Address:" ></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadTextBox ID="txtEmail" runat="server" Skin="Monochrome" Width="159px" SelectionOnFocus="SelectAll">
                        </radI:RadTextBox>
                        <asp:RegularExpressionValidator ID="regEmail" ControlToValidate="txtEmail" Text="(Invalid E-mail Address!)"
                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" runat="server" Font-Size="xx-small" Font-Bold="True"></asp:RegularExpressionValidator>
                    </div>
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblVerifyEmail" runat="server" Text="Confirm E-mail Address:" ></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadTextBox ID="txtVerifyEmail" runat="server" Skin="Monochrome" Width="159px"
                            SelectionOnFocus="SelectAll">
                        </radI:RadTextBox>
                        <asp:CompareValidator ID="CompareEmail" runat="server" ErrorMessage="E-mail Addresses do not match!"
                            ControlToValidate="txtVerifyEmail" ControlToCompare="txtEmail" SetFocusOnError="true" Font-Size="xx-small" Font-Bold="True"></asp:CompareValidator>
                    </div>
                </div>
        </div>
        <div class="info-row gradient">
                <div id='firstname' runat='server'>
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblFirstName" runat="server" Text="First Name*:"></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadTextBox ID="txtFirstName" runat="server" Skin="Monochrome" Width="159px">
                        </radI:RadTextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                            ControlToValidate="txtFirstName" Display="Dynamic"
                            ErrorMessage="First Name is required!"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div id='lastname' runat="server">
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblLastName" runat="server" Text="Last Name*:"></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadTextBox ID="txtLastName" runat="server" Skin="Monochrome" Width="159px">
                        </radI:RadTextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                            ControlToValidate="txtLastName" Display="Dynamic"
                            ErrorMessage="Last Name is required!"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div id='dob' runat="server">
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblDOB" runat="server" Text="Patient's Date of Birth*:"></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadDateInput ID="txtDOB" runat="server" Culture="English (United States)"
                            MinDate="1900-01-01" SelectionOnFocus="SelectAll" Skin="Monochrome" Width="105px">
                        </radI:RadDateInput>
                    </div>
                </div>
                <div id='ssn' runat="server">
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblSSN" runat="server" Text="Patient's Soc. Sec. # *:"></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadMaskedTextBox ID="txtSSN" Mask="###-##-####" PromptChar=" " runat="server"
                            Skin="Monochrome" Width="78px" SelectionOnFocus="SelectAll">
                        </radI:RadMaskedTextBox>
                    </div>
                </div>
                <div id='caregiver' runat="server">
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblCareGiver" runat="server" Text="Are you the Care Giver?:"></asp:Label>
                    </div>
                    <div class='field'>
                        <asp:CheckBox ID="chkCareGiver" runat="server" />
                    </div>
                </div>
                <div id='zip' runat="server">
                    <div class='label' style="width: 170px">
                        <asp:Label ID="lblZip" runat="server" Text="Zip Code:"></asp:Label>
                    </div>
                    <div class='field'>
                        <radI:RadMaskedTextBox ID="txtZip" Mask="#####-####" PromptChar=" " runat="server"
                            Skin="Monochrome" Width="72px" SelectionOnFocus="SelectAll">
                        </radI:RadMaskedTextBox>
                    </div>
                </div>
               
        </div>
        <div class="info-row ">
                <div class='label'>
                    * Indicates required fields
                </div>
                <br /><br />
                <div style="text-align: center;">
                    <asp:Button ID="btnSubmit" Text="Submit" CommandName="Update" OnClick="Submit_Click" runat="server" />
                    &nbsp;&nbsp;
                    <asp:Button ID="btnCancel" Text="Cancel" OnClick="Cancel_Click" CausesValidation="False" runat="server" />
                </div>
                <div class='header'>
                    <asp:RegularExpressionValidator ID="CheckPassword" runat="server" ControlToValidate="txtPassword"
                        SetFocusOnError="true" ValidationExpression="(?=^.{6,}$)(?=.*\d)(?=.*\W+)(?![.\n]).*$"
                        ErrorMessage="Your Password must have at least 1 number, 1 special character, and more than 6 characters."></asp:RegularExpressionValidator>
                </div>
        </div>
    </radA:RadAjaxPanel>
    <radA:AjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Height="75px" Width="75px">
        <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/RadControls/Ajax/Skins/Default/Loading.gif" />
    </radA:AjaxLoadingPanel>
</asp:Content>

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 17 Oct 2008, 09:06 AM
Hi Dan,

Please try to use the ResponseScripts collection in order to register the radAlert. For example:

private void Button1_Click(object sender, System.EventArgs e)
{
      RadAjaxPanel1.ResponseScripts.Add(string.Format("alert('Hello from the server! Server time is {0}');", DateTime.Now.ToLongTimeString()));
}

For more information on this matter please review the following help topic.

Regards,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dan
Top achievements
Rank 2
answered on 17 Oct 2008, 12:41 PM
Thank you.  This method does work for my code case.
Two things:

1. It would be helpful if this alert method were documented in this page:
http://www.telerik.com/support/kb/article/b454K-gtd-b454T-cec-b454c-cec.aspx

2. This method of doing an alert works. But, if your alert message contains a line feed (\n), this results in a javascript error:

Unterminated string constant

Thanks for your help!
0
Maria Ilieva
Telerik team
answered on 20 Oct 2008, 08:00 AM
Hi Dan,

I'm glad to hear that the provided solution works for you.

The alert method is actually presented in this kb article under the third point , but it was shown with some modifications.
Regarding the error you are facing , please review the following forum post which discuses this problem.


All the best,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Dan
Top achievements
Rank 2
Answers by
Maria Ilieva
Telerik team
Dan
Top achievements
Rank 2
Share this question
or