2

I am trying to use update panel in visual webpart(farm solution only) but when i click on button nothing happens

<div>

     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
                   <section id="sec1" class="myclass1">
        <div class="mytit">
            <h2 >Header</h2>
        </div>

        <div id="mydiv" runat="server" >

        </div>
         <div class="row">
            <div class="col-xs-12 ">
                <a class="btn " href="#" role="button" id="btnLoadData"  runat="server" OnServerClick="btnLoadData_Click" >Show rows</a>

            </div>
        </div>
    </section>
         </ContentTemplate>

    </asp:UpdatePanel>

on click event

 protected void btnLoadData_Click(object sender, EventArgs e)
    {
       ShowData();

    }

When i click on button nothing happens and no error in console. If i remove update panel and click on button then it loads data. What is issue here?

  • Do you have anything else on your page apart from this webpart? – Asad Refai Aug 14 '15 at 9:27
  • @AsadRefai i have lot of other html controls which i have put in code above – Happy Aug 14 '15 at 9:29
  • Yes thats correct, I meant do you have any other SharePoint's OOB webparts like CSWP etc. Also have you registered the ajax assembly in your control and placed script manager ? – Asad Refai Aug 14 '15 at 9:31
  • @AsadRefai what do you mean script manager and where to put it? – Happy Aug 14 '15 at 9:33
  • @AsadRefai i now tried to add scriptmanager in my myusercontrol.ascx like <asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true" /> But got error that u should have only script manager on page – Happy Aug 14 '15 at 9:39
0

May be your href="#" is creating your problem. Try to replace it with href="javascript:void(0);".

Best approach would be to use asp.net controls like asp:button or asp.LinkButton instead of pure html a, here you will not be required to place some extra efforts.

  • i have found reason why its not working but dont know how to fix. Its cAUSING because of my master page. While activating feature i set my master page as default. I tried to deactivate feature and then check the page. Update panel works. So its something in master page which is blocking – Happy Aug 17 '15 at 12:09
  • Happy, I am facing the same problem as you with the masterpage. Have you found a solution ? – esbeone Feb 10 '16 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.