Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to When I click on a button or ImageButton then the page is not refreshed.I also used the update panel does not work on server.Thanks for the answer with asp.net2008
Posted
Updated 10-Oct-13 18:35pm
v2
Comments
Homero Rivera 10-Oct-13 19:45pm    
Some ASP.NET code please! C#/VB would be good too. Thanks buddy!
sasan20 10-Oct-13 19:52pm    
i'm use asp.net c# webform creat chatroom widt applicatom and imagebutton replase image for textbox I do not refresh the page.
Tom Marvolo Riddle 11-Oct-13 0:28am    
Use the 'Improve Question' widget to update the question.

If you want to avoid postback while replacing the image in OnClick event of a button or image button.

You can use Update Panel along with Async Postback Trigger.

Your code structure will be like this.

XML
<asp:UpdatePanel ID="UpdatePanelID" runat="server">
   <ContentTemplate>


            //YOUR Image Button/Button

   </ContentTemplate>
                <Triggers>
                         <asp:AsyncPostBackTrigger ControlID="Button/imageButtonID" EventName="Click" />
                </Triggers>
 </asp:UpdatePanel>



Hope it will help.. :)
 
Share this answer
 
my html code :


C#
  <asp:updatepanel id="UpdatePanel2" runat="server" xmlns:asp="#unknown">
    <contenttemplate>
        <div>
            <asp:textbox id="editor" runat="server" cssclass="bord" width="40%" maxlength="80">
                ValidationGroup="1" TabIndex="1"></asp:textbox>
        </div>
<pre lang="vb"><asp:Button ID="Button1" runat="server" Text="send " OnClick="Button1_Click"
              CssClass="btn" Width="10%" ValidationGroup="1"/>



align="center">
<asp:imagebutton id="ImageButton1" runat="server" imageurl="~/yahoo/1.gif" onclick="ImageButton1_Click">
<asp:imagebutton id="ImageButton2" runat="server" imageurl="~/yahoo/2.gif" imagealign="Middle">
OnClick="ImageButton2_Click" />


<triggers> <asp:asyncpostbacktrigger controlid="ImageButton1" eventname="Click">


The labels will show you the contents of the TextBox
C#
 public string chg(string s)
        {
           
            s = s.Replace("[a]","<img src="yahoo/1.gif">");           
            s = s.Replace("[b]", "<img src="yahoo/2.gif">");
   return s;
        }
label.text=user + ":" + chg(editor.Text.ToString());
</img></img>

I was on a updatepanel the client from the server host, but you do not
how to jquery or javascript doesnot refresh to page.
 
Share this answer
 
i'm use asp.net c# webform creat chatroom widt applicatom and imagebutton replase image for textbox I do not refresh the page.
 
Share this answer
 
Comments
VICK 11-Oct-13 0:24am    
Do not use "Add Solution" Option to post any question or comment.

Rather use "Have a Question or Comment?" option.

Secondly do you want to do some coding on button/imagebutton click without refreshing the page?? i.e postback??

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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