1
<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 ?

xyz
  • 61
  • 7

1 Answers1

1

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.

Amit Verma
  • 2,450
  • 2
  • 8
  • 21
  • can you please give me any example link to refer ? i refer to is ispostback =flase but not worked . – xyz Jun 20 '21 at 04:40
  • I used clientclick return flase not worked bro – xyz Jun 20 '21 at 04:40
  • 1
    @xyz clientclick return false only works for java script code. After this your code may not be submitted to server. You can refer example shared by Timur in the comment. – Amit Verma Jun 20 '21 at 04:42
  • 1
    share your complete code. aspx and aspx.cs file code. – Amit Verma Jun 20 '21 at 04:43
  • 1
    That's not how you share code here. Please edit your initial post – Timur Umerov Jun 20 '21 at 05:20
  • i understood it bro thanks for it https://stackoverflow.com/questions/68053152/changing-server-side-code-to-script-not-working but as i am new to this i was unable to convert to script . can you plz have a look on it ? it is big help to me – xyz Jun 20 '21 at 06:15