Reputation: 61
<asp:Panel ID="Panel5" runat="server" >
</asp:Panel>
<asp:Panel ID="Panel6" runat="server" >
</asp:Panel>
<asp:Panel ID="Panel7" runat="server" >
</asp:Panel>
<asp:Button runat="server" ID="addButton" Text="Add More" OnClick="btnMore_click" AutoPostBack ="false" style="margin-left: 877px" Width="84px"/>
as above code , I have three asp panel for each button click ,visible one panel by btnMore_click function .
protected void btnMore_click(object sender, EventArgs e)
{
int count = this.Controls;
if(count == 1)
{
medPanel5.Visible = true;
this.Controls++;
}
if (count == 2)
{
medPanel6.Visible = true;
this.Controls++;
}
if (count == 3)
{
medPanel7.Visible = true;
this.Controls++;
}
}
but currently , when I click button one set visible true . I do not have any issues with it . but I face page reload , each and every time I need to scroll down to click add more button . is there amy way to stop page reload here ?
Upvotes: 1
Views: 1017
Reputation: 2490
This is server side button. ON click of this if you have anything processing on server side than page will post back. Use Ajax if you don't want page post back.
you can use Use Update Panel or Callback too.
Upvotes: 1