Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a panelbar with four panel items. In each panel item click I have to load a usercontrol for that corresponding panelitem. The javascript in usercontrol, which is loaded on PageLoad will work fine. But the javascript in the usercontrol, which is loaded in asyn postback will not work that is the javascript in that usercontrol is not loaded.

My problem is how to add the javascript in that usercontrol, which is added at asyn postback.

It is not working
---->
JavaScript
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "OnSelectData", "<script language='javascript' type='text/javascript'> function OnSelectData(obj,eventargs) { alert('OnSelect'); } </script>", true);


It is also not working
JavaScript
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "Hide", "<script language='javascript' type='text/javascript'> function OnSelectData(obj,eventargs) { alert('OnSelect'); } </script>", true);

Please give a solution for this problem.
Posted
Updated 10-Apr-12 20:08pm
v2
Comments
Pranay Rana 11-Apr-12 2:08am    
endrequest handler is javascript function you can get more info by googling it

Register you function in EndRequestHandler which as given below may work for you...

XML
<script type="text/javascript">
        try {
                        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
        } catch (ex) { }
    </script>


function endRequestHandler() {
        /// <summary>Raised before processing of an asynchronous postback starts and the postback request is sent to the server.</summary>
               try {
              //add you function overe here
            }
        }
        catch (exeption) { }

    };
 
Share this answer
 
Comments
Velkumar Kannan 11-Apr-12 1:56am    
Hi,

Whether the function "endRequestHandler" is a javascript function or C# code.
Hi, Whether the function "endRequestHandler" is a javascript function or C# code.
 
Share this answer
 
Comments
Velkumar Kannan 11-Apr-12 1:58am    
Hi, Whether the function "endRequestHandler" is a javascript function or C# code.
Pranay Rana 11-Apr-12 2:08am    
hi its javascirp function you get more info by googling it
Velkumar Kannan 11-Apr-12 2:17am    
Hi,

I want to add javascript functions not simple codes. Using this function how can I add another functions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900