Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some of problem , if i click Button1, and then hide Button1 and Visible Button2 and Button3. it looks working good, but when i click button1, Page reloaded and then scroll up using mobile page.

i will put source code

What I have tried:

aspx code.
<asp:Button id="Button1" runat="server"  class="btn btn-primary btn-lg"  OnClick="Button1_Click" Text="11:00AM" style= "font-family: Arial, Helvetica, sans-serif;" />
<asp:button id="Button2" runat="server" class="btn btn-outline-info"  OnClick="Button2_Click" Text="Confirm"/>
<asp:button id="Button3" runat="server" class="btn btn-outline-info"  OnClick="Button3_Click" Text="11:00AM"/>



protected void Page_Load(object sender, EventArgs e)
{

    Button1.Visible = true;
    Button2.Visible = false;
    Button3.Visible = false;
  }



protected void Button1_Click(object sender, System.EventArgs e)
       {

           Button2.Visible = true;
           Button3.Visible = true;
           Button1.Visible = false;

       }
Posted
Updated 3-Jul-20 0:13am

1 solution

If you don't want the page to post back, you'll need to use Javascript to change the visibility of the buttons.

Something like this should work:

Code behind:
C#
protected void Page_Load(object sender, EventArgs e)
{
    // Leave all three buttons visible so they are rendered to the HTML output
}
Markup:
ASPX
<asp:Button id="Button1" runat="server"  class="btn btn-primary btn-lg"  OnClientClick="button1Click(); return false;" Text="11:00AM" style= "font-family: Arial, Helvetica, sans-serif;" />
<asp:button id="Button2" runat="server" class="btn btn-outline-info d-none"  OnClick="Button2_Click" Text="Confirm"/>
<asp:button id="Button3" runat="server" class="btn btn-outline-info d-none"  OnClick="Button3_Click" Text="11:00AM"/>
Javascript:
JavaScript
function button1Click(){
    $(this).addClass("d-none");
    $("button[id$='Button2'], button[id$='Button3']").removeClass("d-none");
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900