Run javascript pageLoad function for partial postbacks

2 posts, 0 answers
  1. Igor
    Igor avatar
    10 posts
    Member since:
    Oct 2013

    Posted 11 Dec 2013 Link to this post

    I need to run some javascript code every time on page load, after Telerik Ajax controls are rendered on client. I tried to use this code:

    function SetFocusToField() {
        if (indexToFocus == 0 && controlToFocus) {
    It works fine for the first time (regular page load) but on a partial postback this code doesn't run. I understand why it doesn't work but how can I call this javascript function on partial postbacks?

    I tried to use RegisterStartupScript but it doesn't work for me too :(

    string scriptFocus = @"
        ResetIndexOnFocus = 0;
    ScriptManager.RegisterStartupScript(this, this.GetType(), "scriptFocus", scriptFocus, true);

    Thank you in advance!
  2. msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 11 Dec 2013 Link to this post

    Hi Igor,

    You can use the OnRequestStart feature of the RadAjaxManager to execute JavaScript on every PostBack.  Give it a try and let us know how it works out.

    <script type="text/javascript">
        function requestStart(sender, eventArgs) {
            alert('Request start initiated by: ' + eventArgs.get_eventTarget());
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="requestStart" />

Back to Top