Sharepoint Custom List code-behind not invoked on a embedded page

I have written a custom list in sharepoint, with the onPreRender method populating the list via a webservice. The list needs to stay updated everytime it is rendered. When the list is viewed via the Lists-> MyList , the allitems.aspx is called and my code behind (a WebpartPage) gets called and the list is updated.

But if i embed the list on the front page or anywhere else, my code behind does not get called. It shows the existing list data. What am i doing wrong?

public class GetList: WebPartPage

    protected override void OnPreRender(EventArgs e)

    private void InvokeRefreshList()
        SPList myList = null;
        SPWeb _web;
        _web = SPControl.GetContextWeb(Context);
        _webURL = _web.Url;
        myList = SPContext.Current.List;
        listTitle = myList .Title;
        SPSecurity.CodeToRunElevated elevatedRefreshList = 
            new SPSecurity.CodeToRunElevated(RefreshList);


    private RefreshList(){
         //webservice code.


Assuming that you are dropping the List in the Home Page (Front Page), I would suggest to write a WebPart not a WebPartPage. Because when you drop a list in the Home Page you are indirectly placing the ListViewWebPart, not the Page. So it is obvious that your code is not called.

Need Your Help

Undefined reference, using SFML

c++ pointers sfml

I have begun learning SFML at the same time as C++ and do not understand the rules of using & and * in RenderWindow case. Could you help me?

How to implement pinch to zoom and flick with momentum for a drawing (graph) Core Graphics app?

iphone objective-c core-graphics uitouch

In my app, I drew a graph using Core Graphics (inside a view, inside a view). Not a graphing calc app though, it graphs patient data and marks it every six months, and it is larger than the screen,...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.