如何防止自动回复 [英] How to prevent autopostback

查看:108
本文介绍了如何防止自动回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.net应用程序中使用了两个下拉控件。第二个下拉列表的数据将根据第一个下拉列表选择加载。目前我正在使用autopostback属性,但这将刷新整个页面。我想阻止回发,但当我使用更新面板时,由于某种原因,我将文件复制到服务器的其他功能无法正常工作。有没有其他方法可以阻止回发而不使用更新面板?或者是否有我可以使用的telerik控件?

解决方案

正如您所提到的那样,您正在使用Telerik Controls。

您可以使用RadAjaxManager1来阻止你的回发。

在你的页面加载中你可以使用下面的代码。



 ScriptManager _scriptMan = ScriptManager.GetCurrent( this ); 
_scriptMan.AsyncPostBackTimeout = 36000 ;
RadAjaxManager1.AjaxSettings.AddAjaxSetting(Combobox1,Combobox2);

// 在这里你可以看到我的页面加载我会添加所有的控件避免回发的事件。
// 例如,你可以看到我使用了Radgrid在排序,分页等过程中避免回发。
RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1,RadGrid1);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnSearch,RadGrid1);

RadAjaxManager1.AjaxSettings.AddAjaxSetting(cmdPlant,cmdCarCd);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(txtCustCD,cmdCarCd);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnCustCD,cmdCarCd);





您可以在telerik网站上找到更多详情

http://www.telerik.com/help/aspnet-ajax/ajax -ajaxmanager.html [ ^


I am using two dropdown controls in my .net application. the data for the second dropdown is loaded based on the first dropdown selection. Currently i am using the autopostback property but this will refresh the complete page.I want to prevent the postback but when i use an update panel, for some reason the other functionality where i am copying a file to the server is not working. Is there any other way that i can prevent the postback without using update panel? or is there any telerik control that i can use?

解决方案

As you have mentioned that you are using the Telerik Controls.
You can use "RadAjaxManager1" to prevent your postback .
In your page load you can use the below code.

 ScriptManager _scriptMan = ScriptManager.GetCurrent(this);
        _scriptMan.AsyncPostBackTimeout = 36000;
 RadAjaxManager1.AjaxSettings.AddAjaxSetting(Combobox1, Combobox2);

// here you can see in my page load i will add all the controls which have events to avoid the postback.
// For example here you can see i have used the Radgrid to avoid postback during sorting,paging and etc.
       RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, RadGrid1);
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnSearch, RadGrid1);

        RadAjaxManager1.AjaxSettings.AddAjaxSetting(cmdPlant, cmdCarCd);
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(txtCustCD, cmdCarCd);
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnCustCD, cmdCarCd);



You can find more details from telerik Web site
http://www.telerik.com/help/aspnet-ajax/ajax-ajaxmanager.html[^]


这篇关于如何防止自动回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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