如何在更新面板内部分回发期间存储值

发布于 2024-12-22 07:33:48 字数 619 浏览 8 评论 0原文

我的更新面板中有一个ajax文件上传功能,可以在用户选择要上传的文件后立即上传文件。在 btnVidUpload_Click 中上传文件期间,我将文件名分配给也在更新面板内的隐藏字段。然后,当我单击“提交”时,Send_Click 尝试从隐藏字段中获取值,但隐藏字段为空,为什么隐藏字段会丢失其值,它不能在回发期间保留该值吗?或者有没有一种方法可以存储该值而无需使用会话。谢谢

 <asp:AsyncFileUpload ID="AFU_Video" OnUploadedComplete="btnVidUpload_Click"   
     runat="server" UploaderStyle="Traditional" ThrobberID="aajaxLoader" />

 <asp:HiddenField ID="Hidd_VideoLoc" runat="server" />

 </ContentTemplate>
                </asp:UpdatePanel>

 <asp:ImageButton ID="btn_Send" Text="Submit" runat="server" OnClick="Send_Click"  />

I have a ajax file upload inside my update panel to upload the file immediately after the user selects a file to upload. During the file upload in btnVidUpload_Click I assign the file name to the hidden field which is also inside the update panel. Then when I click Submit Send_Click tries to get the value from the hidden field, but the hidden field is empty, why is the hidden field losing its value, cant it retain the value during post back or is there a way to store the value without using session. thanks

 <asp:AsyncFileUpload ID="AFU_Video" OnUploadedComplete="btnVidUpload_Click"   
     runat="server" UploaderStyle="Traditional" ThrobberID="aajaxLoader" />

 <asp:HiddenField ID="Hidd_VideoLoc" runat="server" />

 </ContentTemplate>
                </asp:UpdatePanel>

 <asp:ImageButton ID="btn_Send" Text="Submit" runat="server" OnClick="Send_Click"  />

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

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

发布评论

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

评论(1

随波逐流 2024-12-29 07:33:48

AsyncFileUpload 在内部使用 iFrame 来呈现 FileUpload 控件。
这就是它似乎失去价值的原因。

您需要使用btnVidUpload_Click中的Session。

自己对类似问题的回答:https://stackoverflow.com/a/8495986/284240

The AsyncFileUpload internally uses an iFrame to render the FileUpload control.
That is the reason why it seems to lose it's value.

You need to use the Session in btnVidUpload_Click.

Own answer on a similar question: https://stackoverflow.com/a/8495986/284240

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文