停止页面刷新图像按钮单击 [英] Stop page refresh on image button click

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

问题描述

你好,



我点击图片按钮时出现问题,整个页面刷新并想停止。



以下是我的代码的一部分。

< br /> 


< p> < div style =height:110px>
 < asp:Label ID =Label9runat =serverText =ماهيإجراءاتحذفمادةالتدريبالميداني?>< / asp:Label>
 < asp:ImageButton ID =ImageButton11runat =serverImageUrl =〜/ Images / add(3).png/>
 < asp:ImageButton ID =ImageButton5runat =serverImageUrl =〜/ Images / minus(1).pngVisible =False/>
< br /> < asp:Label ID =Label3runat =serverText =Visible =False> ;.يمكنحذفمادةالتدريبالميدانيمنخلالالنظامفقط,مع العلمبإناجراءاتالحذفمسموحةلتاريخمعينولايمكنالحذفبعدتجاوزالتاريخالمحدد< / asp:Label>
< / div>
< / p>
< br />





我的尝试:



我试图查看旧帖但我无法解决它

解决方案

这是ImageButton的正常行为,它发布了一个刷新页面的回发。如何停止这取决于单击图像时代码的作用。如果您只想运行像javascript这样的客户端代码,那么请将其设置为普通图像。如果你想在你的代码隐藏文件中运行服务器端代码,那么在asp:UpdatePanel中放置图像按钮和图像按钮更新的任何需求。


你不想要按钮点击后回发。所以,不要使用< asp:imagebutton> ,而是去



如果是某些原因,如果你仍然想使用< asp:imagebutton>然后将代码更新为如下所示:



 imageButton.OnClientClick =button_pressed(); return false;


Hello,

I have a problem when I click on the Image Button, the whole page refresh and want to stop that.

Here is part of my code.

<br />
            

                       <p> <div style="height: 110px">
                 <asp:Label ID="Label9" runat="server" Text="ماهي إجراءات حذف مادّة التدريب الميداني؟"></asp:Label>
 <asp:ImageButton ID="ImageButton11" runat="server" ImageUrl="~/Images/add (3).png" />
 <asp:ImageButton ID="ImageButton5" runat="server" ImageUrl="~/Images/minus (1).png" Visible="False" />
<br /> <asp:Label ID="Label3" runat="server" Text="" Visible="False">.يُمكن حذف مادّة التدريب الميداني من خِلال النظام فقط، مع العِلم بإنّ اجراءات الحذف مسموحة لتاريخ معين ولا يمكن الحذف بعد تجاوز التاريخ المُحدّد</asp:Label>
            </div>
            </p> 
         <br />



What I have tried:

I tried to see old posts but I couldn't fix it

解决方案

That's the normal behaviour of ImageButton, it issues a postback which refreshes the page. How you stop that depends on what your code does when the image is clicked. If you only want to run client-side code like javascript then make it a normal image. If you want to run server-side code in your code behind file then put the image button and whatever needs updated by the image button in an asp:UpdatePanel.


As you don't want postback on button click. So, do not use <asp:imagebutton>, rather go for

If for some reason, if you still want to use <asp:imagebutton> then update your code to something like below:

imageButton.OnClientClick = "button_pressed();return false;"


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

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