Asp:FileUpload 和 RAD ajaxmanager 不能一起工作

发布于 2024-12-08 18:27:12 字数 690 浏览 1 评论 0原文

我有以下用于上传文件的代码:

<asp:Panel ID="pnlCauses" runat="server">
    <asp:FileUpload ID="uplCauses" runat="server" />
    <asp:Button runat="server" ID="btnUplCauses" Text="Upload" OnClick="btnUplCauses_Click" />
    <asp:Label runat="server" ID="lblUplCausesStatus" Text="Upload status: " />
</asp:Panel>

并且我使用以下代码仅允许 pnlCauses 刷新。

<rad:AjaxSetting AjaxControlID="btnUplCauses">
    <UpdatedControls>
         <rad:AjaxUpdatedControl ControlID="pnlCauses" />
    </UpdatedControls>
</rad:AjaxSetting>

但似乎上传控件和 Ajax 不能一起工作。

谁能建议我替代方案?那我怎样才能只允许面板刷新而不完成页面呢?

I have following code for uploading a file:

<asp:Panel ID="pnlCauses" runat="server">
    <asp:FileUpload ID="uplCauses" runat="server" />
    <asp:Button runat="server" ID="btnUplCauses" Text="Upload" OnClick="btnUplCauses_Click" />
    <asp:Label runat="server" ID="lblUplCausesStatus" Text="Upload status: " />
</asp:Panel>

And i have used following code to allow only pnlCauses to refresh.

<rad:AjaxSetting AjaxControlID="btnUplCauses">
    <UpdatedControls>
         <rad:AjaxUpdatedControl ControlID="pnlCauses" />
    </UpdatedControls>
</rad:AjaxSetting>

But seems Upload control and Ajax dont work together.

Can anyone suggest me alternatives ? That how can i allow only panel to refresh and not complete page ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国际总奸 2024-12-15 18:27:12

ASP.NET FileUpload 无法使用 AJAX 调用上传文件。您必须强制回发请求,或使用类似 RadAsyncUpload 异步上传文件。

Telerik 文档为旧版 Telerik ASP.NET 控件提供了解决方法,介绍了如何禁用 RadAjaxPanel 中的上传按钮 AJAX 调用:

<script type="text/javascript">
//on upload button click temporarily disables ajax to perform upload actions
function conditionalPostback(sender, args)
{
  if(args.EventTarget == "<%= ButtonSubmit.UniqueID %>")
  {
    args.EnableAjax = false;
  }
}
</script>
<rada:radajaxpanel runat="server" id="RadAjaxPanel1" 
  clientevents-onrequeststart="conditionalPostback">
  <rad:radupload runat="server" id="RadUpload1" />
  <asp:button id="ButtonSubmit" runat="server" text="Upload" />
</rada:radajaxpanel>

ASP.NET FileUpload cannot upload files using AJAX calls. You must force a postback request, or use a control like RadAsyncUpload to upload files asynchronously.

Telerik documentation has a workaround for older Telerik ASP.NET controls on how to disable upload button AJAX calls in a RadAjaxPanel:

<script type="text/javascript">
//on upload button click temporarily disables ajax to perform upload actions
function conditionalPostback(sender, args)
{
  if(args.EventTarget == "<%= ButtonSubmit.UniqueID %>")
  {
    args.EnableAjax = false;
  }
}
</script>
<rada:radajaxpanel runat="server" id="RadAjaxPanel1" 
  clientevents-onrequeststart="conditionalPostback">
  <rad:radupload runat="server" id="RadUpload1" />
  <asp:button id="ButtonSubmit" runat="server" text="Upload" />
</rada:radajaxpanel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文