单击按钮或图像按钮时不刷新 [英] not refresh when click on button or imagebutton

查看:85
本文介绍了单击按钮或图像按钮时不刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何当我点击一个按钮或ImageButton然后页面没有刷新。我也使用更新面板在服务器上不起作用。感谢asp.net2008的答案

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

推荐答案

如果您想在按钮或图像按钮的OnClick事件中替换图像时避免回发。



您可以使用更新面板异步回发触发器。



您的代码结构将是这样的。



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.

<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.. :)


我的HTML代码:





my html code :


  <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 =ImageButton1runat =serverimageurl =〜/ yahoo / 1.gifonclick = ImageButton1_Click>

< asp:imagebutton id =ImageButton2runat =serverimageurl =〜/ yahoo / 2.gifimag ealign =中>

OnClick =ImageButton2_Click/>


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" />





<触发器> < asp:asyncpostbacktrigger controlid =ImageButton1eventname =Click>





标签会显示内容TextBox



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


The labels will show you the contents of the TextBox

 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>



我在服务器主机上的客户端的updatepanel上,但你没有
如何jquery或javascript不刷新到页面。


I was on a updatepanel the client from the server host, but you do not
how to jquery or javascript doesnot refresh to page.


我使用asp.net c#webform creat chatroom widt applicatom和imagebutton替换textbox文件我不刷新页面。
i'm use asp.net c# webform creat chatroom widt applicatom and imagebutton replase image for textbox I do not refresh the page.


这篇关于单击按钮或图像按钮时不刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆