Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code which gives an runtime javascript error when used inside an update panel.


<script type="text/javascript">
function AddData()
{
// code over here
}
</script>

<asp:ScriptManager ID="ScriptManager1" runat="server">
       </asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
         <asp:ImageButton ID="btnAdd" runat="server" ImageUrl="~/Images/Add.gif" OnClientClick="AddData(); return false;" />
         </ContentTemplate>
</asp:UpdatePanel>

This program give an error , can anyone help how to solve this ?


The error is :
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
Posted
Updated 30-May-12 19:18pm
v7
Comments
hitech_s 31-May-12 1:37am    
i paste your code and executed but i didnt find any error can you check once please
sagar wasule 1-Jun-12 1:32am    
Its not working still :(

Hi Sagar,

This can be due to several issues. May be due to incorrect syntax, or undefined variables or unsupported mehods etc. Share your code inside the AddData() function.

Happy Coding
:)
 
Share this answer
 
try like this. It`s Working fine for me. Ithing In your logic you have errors

XML
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
        </asp:scriptmanager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate >
    <asp:ImageButton ID="ImageButton1" runat="server" Height="50px" Width ="50px"  OnClientClick ="add(); return false;" ImageUrl ="~/images/images.jpeg"/>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>

    </asp:UpdatePanel>

Javascript:

C#
function add()
   {
   alert ('You Clicked image button');
   }
 
Share this answer
 
v2
Comments
sagar wasule 31-May-12 1:14am    
sorry I forgot to mention I have used scriptmanager already , I have updated my question

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