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

radalert to display message for few seconds

3 Answers 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sunil
Top achievements
Rank 1
Sunil asked on 05 Mar 2011, 06:11 AM
Hello Sir/Mam

i'm using radalert to display message. On radButton

OnClientClicked Event

It show message window  for few seconds and disappears........
I'm attaching source code..

  <telerik:RadWindowManager ID="RadWindowManager1" runat="server" 
            EnableShadow="true" 
            DestroyOnClose="true" VIsibleOnPageLoad="true">
        </telerik:RadWindowManager>
  
 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    
    <script type="text/javascript" >
  
        function chkName() 
        {           
            var v1 = document.getElementById("<%=txtName.ClientID%>");
            if (v1.value == "") {
                radalert("Enter username");
                return false;
            }
            else if(v1.value.search("^[a-zA-Z. ]{1,40}$") != 0)
            {
                radalert("Enter valid username", 300, 200, "NAME VALIDATION");
                return false;
            }
            else 
                  
                return true;
              
        }
  
         
    </script>   
  </telerik:RadCodeBlock>
  
    <table>
        <tr>
            <td>Name</td>
            <td
                <telerik:RadTextBox ID="txtName" runat="server" />               
            </td>
            <td>
                <telerik:RadButton ID="btnName" runat="server" OnClientClicked ="chkName" />                
            </td>
        </tr>
</table>



Help!!!1


Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 09 Mar 2011, 08:49 AM
Hi Sunil,

The RadWindow disappears because of the page postback initiated by the button click. To override it you have to:

  • add the handler to the OnClientClicking event, as canceling the postback is already impossible at the OnClientClicked event
  • add the necessary arguments to your validation function: sender, args
  • use the set_cancel() method to prevent the postback

I have attached a simple page to show this approach, which you can implement in your case.

For further information on canceling a postback you can take a look at the new RadButton demo.


Best wishes,
Marin
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Emad
Top achievements
Rank 1
answered on 20 Jul 2016, 06:56 PM

Hi,

 

Below code I can't pass sender and args.

how to cancel post back

 

$.ajax({
                    type: "POST",
                    url: "physician.aspx/savePage",
                    data: '{buttonID: "' + buttonID + '", visitID: "' + visitID + '", patientID: "' + patientID + '",userName: "' + userName + '", clientID: "' + clientID + '", clinicID: "' + clinicID + '", appointmentID: "' + appointmentID + '", newVisit: "' + newVisit + '", previousVisitID: "' + previousVisitID + '", temprature: "' + temprature + '", bloodPressure: "' + bloodPressure + '", text01: "' + text01 + '", text02: "' + text02 + '", text03: "' + text03 + '", text04: "' + text04 + '", text05: "' + text05 + '", text06: "' + text06 + '", text07: "' + text07 + '", text08: "' + text08 + '", text09: "' + text09 + '", text10: "' + text10 + '", text11: "' + text11 + '", text12: "' + text12 + '", text13: "' + text13 + '", text14: "' + text14 + '", text15: "' + text15 + '", text16: "' + text16 + '", text17: "' + text17 + '", text18: "' + text18 + '", text19: "' + text19 + '", text20: "' + text20 + '", checkBox01: "' + checkBox01 + '", checkBox02: "' + checkBox02 + '", checkBox03: "' + checkBox03 + '", checkBox04: "' + checkBox04 + '", checkBox05: "' + checkBox05 + '", checkBox06: "' + checkBox06 + '", checkBox07: "' + checkBox07 + '", checkBox08: "' + checkBox08 + '", checkBox09: "' + checkBox09 + '", checkBox10: "' + checkBox10 + '", list01: "' + list01 + '", list02: "' + list02 + '", list03: "' + list03 + '", list04: "' + list04 + '", list05: "' + list05 + '", list06: "' + list06 + '", list07: "' + list07 + '", list08: "' + list08 + '", list09: "' + list09 + '", list10: "' + list10 + '", date01: "' + date01 + '", date02: "' + date02 + '", date03: "' + date03 + '", date04: "' + date04 + '", date05: "' + date05 + '", date06: "' + date06 + '", date07: "' + date07 + '", date08: "' + date08 + '", date09: "' + date09 + '", date10: "' + date10 + '", visitCompleted: "' + visitCompleted + '"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: false,
                    success: OnSuccess,
                    failure: function (response) {
                        alert(response.d);
                    }
                });

            }
            else {
                //alert('Page is not valid!');
                return;
            }

        }
        function OnSuccess(response) {
            $find("<%= VISIT_ID.ClientID %>").set_value(response.d);
            saveTowGrids();
            //alert('Save Completed');
            radalert('Save Completed', 250, 150, 'Save');//, alertNoCallBackFn, $dialogsDemo.imgUrl);
            response.set_cancel(true);//cancel post back
        }

0
Marin Bratanov
Telerik team
answered on 21 Jul 2016, 07:25 AM

Hi Emad,

The success event of the jQuery ajax() method is called after the response is returned from the server, so you cannot cancel the POST in it. You can use the beforeSend event to do that. You can read more about this in the jQuery documentation: http://api.jquery.com/jquery.ajax/.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Sunil
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Emad
Top achievements
Rank 1
Share this question
or