避免页面刷新按钮单击。 Asp.net C# [英] Avoid page refresh on button Click. Asp.net C#

查看:92
本文介绍了避免页面刷新按钮单击。 Asp.net C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我点击按钮页面时,我在一个页面上有多个按钮刷新...我怎么能阻止这个?我不希望按钮点击刷新页面...我正在使用Asp.net C#..



请帮助.....

I have multiple Buttons on one page whenever i click on button page Refresh... How can i stop this ? i dont want that page refresh on button click... i am using Asp.net C#..

Please Help.....

推荐答案

1.默认情况下,每个按钮都会生成一个页面回发到Web服务器,结果页面内容被发送到Web服务器,页面事件被执行,最后页面以HTML格式发送回浏览器,浏览器呈现页面。



2.为避免整页回发,您有更多选择:

i)设置 AutoPostBack 属性为false并使用与 OnClick 事件关联的JavaScript和AJAX调用;有关在ASP.NET中使用jQuery和AJAX调用的详细信息,请参阅:调用a在客户端使用jQuery的C#方法 [ ^ ]



ii)使用 UpdatePanel 仅限将刷新使用过的面板的区域,而不是整个页面。查看有关更新面板的详细信息: http://msdn.microsoft.com /en-us/library/vstudio/bb399001(v=vs.100).aspx [ ^ ]
1.By default each button generate a postback of the page to the web server, and as result the page content is send to the web server, the page events are executed and at the end the page is sent back in HTML format to the browser and the browser render the page.

2.To avoid the entire page postback you have more options:
i)set AutoPostBack attribute on false and use JavaScript and AJAX call associated with the OnClick event; For details about using jQuery and AJAX call in ASP.NET see: Calling a C# method using jQuery on the client side[^]
OR
ii)use UpdatePanelso only the area of the used panel will be refreshed and not the entire page. See details about update panel: http://msdn.microsoft.com/en-us/library/vstudio/bb399001(v=vs.100).aspx[^]


这篇关于避免页面刷新按钮单击。 Asp.net C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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