Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
2.09/5 (3 votes)
See more:
hello,
my requirement is i want to stop page refresh on button click but my button click event should fire.
i have tried this

1.
XML
<asp:button ID="Button1" runat="server" text="Button" OnClientClick="return false;" />

or in the CodeBehind:
2. Button1.Attributes.Add("onclick", "return false;");


3.<asp:button id="Button1" runat="server" text="Button" onclientclick="return false;" autopostback="false" xmlns:asp="#unknown" />

in thired case code behind event is not getting fired.

but on click event is not getting fired.pls tell me how to fire button click event without page refresh
Posted
Updated 30-Jan-19 19:36pm
v2

Try

ASP.NET
<asp:button id="Button1" runat="server" text="Button" onclientclick="return false;" autopostback="false" xmlns:asp="#unknown" />
 
Share this answer
 
You can make use of Web method. Create click of the button using JQuery and from that call web method. You can find tons of examples on internet regarding this. If you still need help, let me know.

Regards..
 
Share this answer
 
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="up1" runat="server">
    <ContentTemplate>
   
   <asp:Button ID="btn" runat="server" Text="Button"  />

    </ContentTemplate>
    </asp:UpdatePanel>
 
Share this answer
 
I have a grid, which contains a text box. By default, the grid contains 10 rows. When I click on add new row button the 11th row will be added, but the entered previous details will be cleared off. Please give me the solution so that the previous details are not cleared on the button click.
 
Share this answer
 
Comments
CHill60 21-Aug-18 4:14am    
If you have a question then use the red "Ask a question" link at the top of this page. Do not post questions or comments as solutions to other posts - well not if you want an answer anyway.
You will need to include your code in your question
when we click on Add button in the grid (row adding) then page is refresh and data is not seen .what is proper solution .
 
Share this answer
 
Comments
CHill60 31-Jan-19 3:47am    
If you have a question then use the red "Ask a question" link at the top of the page. Do not post questions or comments as solutions to other posts. You will need to include your code in your question

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