locked
Javascript code inside the updatepanel Not Working RRS feed

  • Question

  • User1944504294 posted

    Hi ,

    Please help.

    Javascript code inside the updatepanel  in .aspx page is Not Working.

    How to write the java script code inside the update panel in the .aspx page itself without calling from server page .cs

    Best regards,
    Renuka.V

    Saturday, January 10, 2015 1:21 AM

Answers

All replies

  • User-760709272 posted

    You'll have to explain a bit more, or at least show the code you've tried that doesn't work and explain what it is you're trying to achieve.  To get js working with updatepanels you normally need to use the ScriptManager methods, but as you haven't given any details it is hard to recommend a solution.

    Saturday, January 10, 2015 8:48 AM
  • User1944504294 posted

    Hi,

    Here the code.

    I need to create the  images at run time using the java script. Please see the code below the image is created from the java script.

     <ajax:UpdatePanel ID="upRegister" runat="server" UpdateMode="Always">
            <ContentTemplate>

    table cellpadding="0" cellspacing="0" border="0" width="605">
                                                        <tr>
                                                            <td width="370" align="left"  style="padding:0px;" >
                                                                <asp:Button ID="btnSave"  runat="server" Text="submit"
                                                                    ValidationGroup="CreateUser" TabIndex="28" UseSubmitBehavior="true" OnClick="btnSave_Click"
                                                                    Style="width: 70px;" />
                                                            </td>
                                                               
                                                                    <td align="right" rowspan="2" style="padding-right:10px;">
                                                                    <asp:ImageButton ID="imgVerify" runat="server" ImageUrl="~///secured.png" OnClientClick="javascript:return verifySeal();"   />
                                                                         
                                                                    </td>
                                                               
                                                                <td rowspan="2" align="right">                                                    
                                                                <div class="VerifiedCerificateSeal">
                                                                <script type="text/javascript" language="javascript">  var ANS_customer_id = "UinqueidnetiiferId";</script>
                                                                <script type="text/javascript" language="javascript" src="////cerificadeseal.js" ></script> (Here creating the seal from the js file)
                                                                </div>
                                                                </td>
                                                        </tr>
                                                    </table>

    ...
        </ajax:UpdatePanel>

    Here I need to create that image from the java script without going to any other page .

    Please help me!

    Thank you!

    Renuka.V

    Monday, January 12, 2015 1:21 AM
  • User1918509225 posted

    Hi Renuka,

    I suggest that you first try to add the javascript file in your head not in the body like below:

    <head>
        <script type="text/javascript" language="javascript" src="////cerificadeseal.js" ></script> (Here creating the seal from the js file)
    </head>

    Then ,please try to press F12 to debug your javascript code and check if it has any error message.

    Best Regards,

    Kevin Shen.

    Monday, January 12, 2015 4:09 AM
  • User1944504294 posted

    Hi Kevin,

    First up all thank you!

    It is working in the head tag but not inside the body tag.

    But I'm in the situation to put that seal only inside the body . Within that td only I need to display that seal.

    What can I do for that ?? Can you please help

    Best regards,
    Renuka.V

    Monday, January 12, 2015 4:25 AM
  • User1918509225 posted

    Hi Renuka V,

    For there have Conflicts between ASP.NET AJAX UpdatePanels & jQuery functions, because after partial post-back has been made by the ASP.NET AJAX UpdatePanel, the JavaScript event handlers are lost,so the javascript code will not work inside the updatepanel.

    I suggest that you could try the solution in the link below:

    http://weblogs.asp.net/hajan/make-them-to-love-each-other-asp-net-ajax-updatepanels-amp-javascript-jquery-functions

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 13, 2015 10:18 PM