Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using two javascript functions inside the updatepanel,
1) Calendar
2) Autocomplete

I want to put all this page controls inside the Update panel. If i remove the Updatepanel then javascript will work else it won't. How can i make it work the javascript inside updatepanel.

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
                <ajax:ScriptManager id="ScriptManager1"  runat="server">
<ajax:UpdatePanel id="UpdatePanel1"  runat="server">
<link rel='stylesheet' href="../Calendar/calendar.css" title='calendar'/>
<script type="text/javascript" language="javascript" src="../Calendar/calendar.js"></script>
 <script src="../scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../Scripts/jquery.autocomplete.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {

<asp:TextBox ID="txtDte" runat="server" CssClass="textbox" Enabled="False" ReadOnly="True"><img id="imgDte"  runat="server" align="middle"
                    alt=""  önmouseover="fnInitCalendar(this, 'txtDte', 'style=calendar.css,close=true')"
                    src="../Calendar/cal.gif" visible="false" />

<asp:TextBox ID="txtSearch" runat="server" CssClass="textbox"
                TabIndex="1" Width="300px">
Updated 9-Sep-12 20:40pm

'$(document).ready' fires ONLY when the page loads completely or after full postbacks. Since you are using it inside the UpdatePanel which does a partial postback, it will NOT be fired.

Place the Javascript outside the UpdatePanel, it will work...
Share this answer
Robymon 10-Sep-12 3:37am    
Yes, it is working now. But $(document).ready(function() works only once( first time the page loads ), it is not working if we click any button or any server side event.
bbirajdar 10-Sep-12 9:16am    
Great.. I am glad I could help you
It's probably the same conflict that happens between jquery and updatepanels. Here you're using jquery, but I am sure it's the same type of issue. Basically the updatepanel is not refreshing the entire DOM so the other js library's functions never get called. Refer the link below for the similar thread:
Conflicts between ASP.NET AJAX UpdatePanels & jQuery functions[^]

Share this answer
javascript is run only for single time when pageloads if you want to access javascript in the update panel then you need to use this


Share this answer
Share this answer

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