如何避免在Asp.net中刷新页面? [英] How to AVOID Page Refresh in Asp.net ?
问题描述
亲爱的朋友,
如何避免Asp.net中的页面刷新
===================================
我有一个包含3个文本框和登录按钮的登录页面
=======================================
用户名-Textbox1(TxtUserName)
DisplayName-Textbox2(TxtDisplayName)
密码-Textbox3(TxtPassword)
登录按钮
=========================================
输入用户名并按Tab键时,显示名称自动显示....但是页面正在刷新.
如何避免这种情况,请帮助我. THANX.
Dear Friends,
How to Avoid Page Refresh in Asp.net
====================================
I have a login page with 3 textboxes and login button
=========================================
UserName - Textbox1(TxtUserName)
DisplayName - Textbox2(TxtDisplayName)
Password - Textbox3(TxtPassword)
Login Button
============================================
when am entering UserName and pressing tab...,display name automatically displays....BUT PAGE IS REFRESHING.
how to avoid this, Please help me. THANX.
推荐答案
基本上,当您需要使用jQuery进行客户端调用时,您正在使用POST进行服务器请求.这是如何执行此操作的说明:
http://www.sitepoint.com/forums/showthread. php?633180-Refresh-DIV-Content-Without-Reloading-Page [ http://stackoverflow.com/questions/7956461/jquery-update-a-div-on-page-无刷新页面 [
Basically, you are doing a server-request using a POST when you need to use jQuery to do a client-side call. Here is an explanation of how to do this:
http://www.sitepoint.com/forums/showthread.php?633180-Refresh-DIV-Content-Without-Reloading-Page[^]
or here:
http://stackoverflow.com/questions/7956461/jquery-update-a-div-on-page-without-refreshing-the-page[^]
请使用AJAX.如果使用AJAX(ScriptManager,UpdatePanel,Contenttemplate),则页面无法刷新.
将您的控件放在ContentTemplate
中
Please use AJAX. If you use AJAX (ScriptManager, UpdatePanel, Contenttemplate) the Page cannot refresh.
Place your Controls here within ContentTemplate
<asp:ScriptManager ID="SavedScriptManager" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="savedUpdatePanel" runat="server">
<ContentTemplate>
如果在txtUsername
文本框中输入用户名后我没错,那么您要显示该用户的名称,因为您已经放置了AutoPostback=true
.哪个是对的.但是在这种情况下,您需要用户名而不刷新页面.
为避免页面刷新,请使用updatepanel
If I am not wrong after entering Username in yourtxtUsername
Textbox, you want to display the name of that User, for that you had put theAutoPostback=true
. which is right. but In this scenario you want the username without refreshing the page.
For avoiding page refresh useupdatepanel
这篇关于如何避免在Asp.net中刷新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!