0

I am using Server Side code to do Paging on SharePoint List. I am using Visual Web Part to show items from List.

protected void Page_Load(object sender, EventArgs e)
{

   if (!this.Page.IsPostBack)
   { 
       // below function loads data from sharepoint list. Not showing whole logic as its not required
       LoadDataFromSharepointList(); 
   }
}

When I load data it loads whole Page. Is it possible to load only that Web Part instead of whole Page. Any examples?

Update1

I tried to use Ajax update panel in ascx file

<asp:updatepanel runat= "server>
     <div>
<section id="ideas" class="container">
     <div>
        <div>
            <a href="#" role="button" id="btnShow"  runat="server" OnServerClick="btnShow_Click">Get data</a>

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

But in my code behind i cannot get divTest and it throws compile time error. Whats wrong in this?

6
  • asp:panel is not UpdatePanel. Second to access control from server side you need to mark runat="server" Jun 5, 2015 at 22:14
  • @AmalHashim you see i have marked them already
    – Happy
    Jun 5, 2015 at 22:16
  • @AmalHashim i get Error The name 'InitializeControl' does not exist in the current context . The name divTest does not exist in current context.
    – Happy
    Jun 5, 2015 at 22:21
  • Try cleaning solution and rebuild Jun 5, 2015 at 22:22
  • @AmalHashim i tried but same error. Remember i am using visual web part
    – Happy
    Jun 5, 2015 at 22:23

2 Answers 2

0

There are a few issues with your code.

First off, you have not declared the UpdatePanel correctly. You are missing the closing double-quote on the runat attribute and you are missing the ContentTemplate element. This is an example of a correctly declared UpdatePanel from this article on MSDN:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <fieldset>
            <legend>UpdatePanel</legend>
            <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
            </fieldset>
        </ContentTemplate>
    </asp:UpdatePanel>

Second, even if you declared the UpdatePanel correctly it would have no effect. The UpdatePanel works with Server Controls, not raw HTML elements.

0

You need to use Ajax to do this.

In ASP.Net for implementing this in Server Side we use UpdatePanel. For more you can check asp.net community site https://ajaxcontroltoolkit.codeplex.com/documentation

You can also use client side for implementing the same. In client side you either JavaScript object model or REST API to query data and load it to table etc using jQuery.

1
  • i have already tried to use update panel. see edited question
    – Happy
    Jun 5, 2015 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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