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

How to show RadInputManager error message from javascript if not postback.

4 Answers 169 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wai Loon
Top achievements
Rank 1
Wai Loon asked on 03 Nov 2009, 06:59 AM
Hi,
I have a popup screen which allowed user to enter the address.
Some fields are mandatory, so if user didn't enter for those fields, error message should show.
That popup screen don't have c# codes and totally no post back. All events/functions are done in Javascript.
Now the problem is the error message didn't show when I click on the 'Save' button. It just didn't close the popup screen cause of the mandatory fields.
I have tried to do a manual post back from javascript ('Form1.Submit();');
The text box are in red border and alert logo also shown, but the error message still not coming out.
Please help.
Below is the source code for the popup screen.

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
    <style type="text/css" media="all">  
        @import "/css/standard.css";  
    </style> 
 
    <script src="/js/jquery-1.2.6.min.js" type="text/javascript"></script> 
 
    <script src="/js/common.js" type="text/javascript"></script> 
 
    <script language="javascript" type="text/javascript">  
        function GetRadWindow(){  
            var oWindow = null;  
            if (window.radWindow) oWindow = window.radWindow;  
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
            return oWindow;  
        }  
        function PopulateData()  
        {  
            var oObject = GetRadWindow().argument;  
              
            document.getElementById('txtAddressLine1').value = oObject.Company;  
            document.getElementById('txtAddressLine2').value = oObject.Address1;  
            document.getElementById('txtAddressLine3').value = oObject.Address2;  
            document.getElementById('txtCity').value         = oObject.City;  
            document.getElementById('txtState').value        = oObject.State;  
            document.getElementById('txtCountry').value      = oObject.Country;  
            document.getElementById('txtPostal').value       = oObject.Postcode;  
              
            document.getElementById('txtAddressLine1').readOnly = oObject.ReadOnly;  
            document.getElementById('txtAddressLine2').readOnly = oObject.ReadOnly;  
            document.getElementById('txtAddressLine3').readOnly = oObject.ReadOnly;  
            document.getElementById('txtCity').readOnly         = oObject.ReadOnly;  
            document.getElementById('txtState').readOnly        = oObject.ReadOnly;  
            document.getElementById('txtCountry').readOnly      = oObject.ReadOnly;  
            document.getElementById('txtPostal').readOnly       = oObject.ReadOnly;  
 
            if (oObject.ReadOnly)  
            {  
                document.getElementById('btnSave').style.visibility = "hidden";  
                document.getElementById('divButton').style.visibility = "hidden";  
            }  
            else  
            {  
                document.getElementById('btnSave').style.visibility = "visible";  
                document.getElementById('divButton').style.visibility = "visible";  
            }  
        }  
          
        function returnToParent(strMode)  
        {  
            //create the argument that will be returned to the parent page  
            var arg  = new Object();  
              
            if( (strMode != null) && (strMode == 'Save'))  
            {  
                arg.Company   = document.getElementById('txtAddressLine1').value;  
                arg.Address1  = document.getElementById('txtAddressLine2').value;  
                arg.Address2  = document.getElementById('txtAddressLine3').value;  
                arg.City      = document.getElementById('txtCity').value;  
                arg.State     = document.getElementById('txtState').value;  
                arg.Country   = document.getElementById('txtCountry').value;  
                arg.Postcode  = document.getElementById('txtPostal').value;  
            }  
              
            //get a reference to the current RadWindow  
            var oWnd = GetRadWindow();  
              
            //Close the RadWindow and send the argument to the parent page  
            oWnd.close(arg);  
        }  
    </script> 
 
</head> 
<body onload="PopulateData()">  
    <form id="form1" runat="server">  
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Default, Label" /> 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">  
    </telerik:RadAjaxLoadingPanel> 
    <telerik:RadAjaxPanel ID="ajaxPanelAccount" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
        <telerik:RadInputManager ID="radMgrMandatoryFields" runat="server">  
            <telerik:RegExpTextBoxSetting BehaviorID="mandatoryField" EmptyMessage="<%$ Resources:Error, MandatoryCardGroupName %>" 
                     ErrorMessage="<%$ Resources:Error, MandatoryCardGroupName %>" IsRequiredFields="true">  
                <TargetControls> 
                    <telerik:TargetInput ControlID="txtAddressLine1"/>  
                    <telerik:TargetInput ControlID="txtCity"/>  
                    <telerik:TargetInput ControlID="txtCountry"/>  
                    <telerik:TargetInput ControlID="txtPostal"/>  
                </TargetControls> 
        </telerik:RadInputManager> 
        <div> 
            <table width="98%" cellpadding="10px">  
                <tr> 
                    <td> 
                        <div id="tb_card_settings">  
                            <h2> 
                                <asp:Literal ID="ltrlDeliveryAddressTitle" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlDeliveryAddressTitle%>"></asp:Literal> 
                            </h2> 
                            <div> 
                                <div class="">  
                                    <table> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlAddressLine1" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlAddressLine1 %>"></asp:Literal> 
                                            </td>   
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtAddressLine1" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlAddressLine2" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlAddressLine2 %>"></asp:Literal> 
                                            </td> 
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtAddressLine2" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlAddressLine3" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlAddressLine3 %>"></asp:Literal> 
                                            </td> 
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtAddressLine3" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlCity" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlCity %>"></asp:Literal> 
                                            </td> 
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtCity" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlState" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlState %>"></asp:Literal> 
                                            </td> 
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtState" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlCountry" runat="server" Text="<%$ Resources:Common, ltrlCountry %>"></asp:Literal> 
                                            </td> 
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td style="width:30%">  
                                                <asp:Literal ID="ltrlPostal" runat="server" Text="<%$ Resources:DeliveryAddress.aspx, ltrlPostal %>"></asp:Literal> 
                                            </td> 
                                            <td style="width:70%">  
                                                <asp:TextBox ID="txtPostal" runat="server"></asp:TextBox> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </div> 
                            </div> 
                            <p></p>  
                            <div Id="divButton" runat="server">  
                                <class="buttons">  
                                    <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:Button, btnSave %>" OnClientClick="returnToParent('Save'); return false;" /> 
                                </p> 
                            </div> 
                        </div> 
                    </td> 
                </tr> 
            </table> 
        </div> 
    </telerik:RadAjaxPanel> 
    </form> 
</body> 
</html> 
 

4 Answers, 1 is accepted

Sort by
0
Wai Loon Ho
Top achievements
Rank 1
answered on 06 Nov 2009, 01:54 AM
Anyone know about this?
0
Sebastian
Telerik team
answered on 06 Nov 2009, 09:12 AM
Hi Wai,

I reviewed your code and here are my suggestions:
  1. I see that you placed the asp ScriptManager inside the RadAjaxPanel instance. Please move it outside of the ajax panel and position it as first control on the page (before the RadFormDecorator) as this is the proper means to use it.
  2. Remove temporary the RadFormDecorator control to see whether this produces different result.
  3. Set static ErrorMessage for the RegExTextBoxSetting (instead of taking it from resources) to see whether this makes a difference.
  4. Double-check whether the error message is displayed inside the textboxes with value which does not match the regex as shown in the last group on this demo.
  5. Verify that you are using the latest version 2009.3.1103 of RadControls for ASP.NET AJAX in your project (Q3 2009)

Let us know what your findings are.

Kind regards,

Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wai Loon Ho
Top achievements
Rank 1
answered on 12 Nov 2009, 09:05 AM
Hi,
I have tested from 1 - 4 except no 5.
But is not working, the error message is sitll not coming out.

Is there any other posibility??
0
Sebastian
Telerik team
answered on 12 Nov 2009, 10:41 AM
Hi Wai,

If these directions are not helpful, I suggest you isolate a stripped working version of your project, illustrating the abnormality, and send it attached to a regular support ticket. I will test it locally and will get around to you with my findings.

Also verify that you tested the case with the latest release 2009.3.1103 of the suite following the upgrade instructions from here.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Wai Loon
Top achievements
Rank 1
Answers by
Wai Loon Ho
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or