如何避免autopostback上的页面刷新 [英] how to avoid page refresh on autopostback

查看:512
本文介绍了如何避免autopostback上的页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,我正在研究asp.net c#sql。



我在数据库中有Seri​​alNos来填充Textbox。此SerialNo是为创建票证而发行的。



我将SerialNo从数据库中恢复为文本框20001.



我在此页面上还有一个下拉列表,其autopostback属性为true。



当我从下拉列表中选择项目时,它会获得回发并刷新页面...和值文本框更改为20002



请您给出解决方案。

解决方案

在使用我们的应用程序期间如果我们在文本框控件中输入任何值并单击表单中的按钮,我们将看到页面的完整回发,我们将丢失所有控件值,无论我们之前输入的是什么,因为回发。如果我们想避免这个完整的页面回发和往返服务器,我们需要编写很多代码而不是编写很多代码我们可以使用ajax updatepanel控件。

Ajax updatepanel将帮助我们避免完全回发该页面,即避免刷新整个页面内容与回发和停止闪回与回发相关联的页面,并只允许部分回发。通过使用Ajax updatepanel,我们只刷新页面所需的部分而不是刷新整个页面。

< asp:updatepanel id =UpdatePanel2runat =serverxmlns:asp = #未知 > 
UpdateMode =条件>
< contenttemplate>
< asp:textbox id =txtValrunat =serverautopostback =Trueontextchanged =txtVal_TextChanged/>
..........................................
< / ASP:文本框>< /&的ContentTemplate GT;
< / asp:updatepanel>



获取更多信息

understanding-asp-net-ajax-updatepanel-triggers [ ^ ]


您好,

ASP.Net是服务器端。您编写的每个代码都在服务器端执行。每个事件都会刷新页面。完整的页面循环如下。

为了避免回发,你必须使用ajax.if你不是ajax的familair。你必须参考以下链接:

Ajax Link



ajax上的Tutorail



Ajax for beginers



希望它可以帮到你


现在在这种情况下你可以使用页面的Ispostback属性。并且尽量不要在回发中点击sql server。



或者如果你不希望页面汇总到服务器那么你必须使用jquery或ajax。

hi experts, am working on asp.net c# sql.

I have SerialNos in Database to fill Textbox. This SerialNo is Issued for Creating Tickets.

Am Retreving SerialNo into Textbox from Database as 20001.

I have a dropdownlist also on this page its autopostback property is true.

When I select item from dropdownlist it gets postback & Refreshes the Page ...and the value of the Textbox changes to 20002

Please can you give the solution.

解决方案

During work with our applications if we entered any values in textbox controls and click on a button in form we will see full postback of our page and we will lost all the controls values whatever we entered previously this happend because of postback. If we want to avoid this full postback of page and round trip to server we need to write much code instead of writing much code we can use ajax updatepanel control.
Ajax updatepanel will help us to avoid full postback of the page i.e., avoid refresh of the whole page content with postback and stop flickering of the page which is associated with a postback and allows only partial postbacks. By using Ajax updatepanel we can refresh only required part of page instead of refreshing whole page.

<asp:updatepanel id="UpdatePanel2" runat="server" xmlns:asp="#unknown">
 UpdateMode="Conditional">
 <contenttemplate>
<asp:textbox id="txtVal" runat="server" autopostback="True" ontextchanged="txtVal_TextChanged"/>
..........................................
 </asp:textbox></contenttemplate> 
 </asp:updatepanel>


Get More info here
understanding-asp-net-ajax-updatepanel-triggers[^]


Hello ,
ASP.Net is a server side.Every Code you write executes on the server side.The page gets refreshed with every event & the complete page cycle follows.
In order to avoid postback ,you have to use ajax.if you are not familair with ajax . you have to refer following link:
Ajax Link

Tutorail on ajax

Ajax for beginers

Hope it helps you


Right now in this scenario you can use Ispostback property of the page. and try not to hit the sql server in postbacks.

or if you don't want the page to sumbit to server then you have to use jquery or ajax.


这篇关于如何避免autopostback上的页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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