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

Stop RadWindow postback after javascript event

2 Answers 97 Views
Window
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 07 Aug 2013, 06:15 PM
I have a radwindow in which I have a button execute some javascript which manipulates the css classes of some elements. I see that this works, but then the content posts back and refreshes and the changes that the javascript just made get wiped out. How can I stop the radwindow from reloading after I execute a javascript function?

Here is the code for the button on the page loaded in the RadWindow:
<div style="padding:10px 10px 10px 10px; position:fixed; background-color:white; width:100%; z-index:100; height:15px;">
    <table>
             <tr>
                <td>
                    <button id="btnModify" onclick="ShowModify(); return false;">Modify</button>
                </td>
             </tr>
  </table>
</div>


And here's the javascript I have in the RadWindow:
function ShowModify()
{
        var elems = document.getElementsByTagName("span");
        for (i in elems)
        {
             if (elems[i].className == "modifyField")
             {
                  elems[i].className = "modifyFieldVisible";
             }
         }
         return false;
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 08 Aug 2013, 10:47 AM
Hi Gary,

Does this work when placed directly on the page outside of a RadWIndow? I am asking because RadWindow does not modify its content, so it cannot generate a postback by itself. The most likely reason I can see for the behavior you describe is a JS error in the custom code that you are using. It is also entirely possible that something else on the page is causing the postback, e.g. a timer.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Gary
Top achievements
Rank 1
answered on 08 Aug 2013, 05:28 PM
Marin,
Good suggestion! I did exactly that and found that it was a javascript exception that was thrown that was causing the page to postback.

Thanks!
Tags
Window
Asked by
Gary
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Gary
Top achievements
Rank 1
Share this question
or