Loading the Web Parts in the Page Load Event
When you have the ASP.NET web parts load logic in the pageload event surrounded by the !IsPostBack(page is loaded for the first time) branch, you will notice that the webparts wouldn't load. When you remove the if(!IsPostback) condition, web parts load correctly.
To workaround this issue, please follow these steps:
Step 1:
Place a lable on your .aspx file. Make the visibility as false and Text as true.
<asp:Label ID="lbIsPostBack" runat="server" Text="true" Visible="false"/>
Step 2:
Add the follwing code to your code behind file.
protected void Page_Load(object sender, EventArgs e)
{
if (lbIsPostBack.Text == "true")
{
lbIsPostBack.Text = "false";
LoadWebPart();
}
}
Alternate Titles: C# Web Parts Postback Issue,Web Parts Load Issue