如何在Update和Tab面板中使用Fileupload [英] How to use Fileupload inside Update and Tab panel

查看:75
本文介绍了如何在Update和Tab面板中使用Fileupload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用触发器。

错误信息如下



无法找到触发器ID为btnupload的控件在UpdatePanel ..



如何找到按钮控件ID,或者还有其他任何方式。



后端代码



I tried using trigger .
Error message as below

A control with ID 'btnupload' could not be found for the trigger in UpdatePanel..

How to find the button control ID, or is there any other way.

Backend Code

string excelPath = Server.MapPath("~/Files/") + Path.GetFileName(FileUpload1.PostedFile.FileName);
        FileUpload1.SaveAs(excelPath);

        string conString = string.Empty;
        string extension = Path.GetExtension(FileUpload1.PostedFile.FileName);







ASPX代码



< updatepanel>




ASPX Code

<updatepanel>

<asp:TabPanel ID="TabPanel7" runat="server" HeaderText="TabPanel7">
                    <ContentTemplate>
                        <br />
                        <asp:FileUpload ID="FileUpload1" runat="server" />
                        <asp:Button ID="btnupload" runat="server" OnClick="Button1_Click" Text="Button" />

                    </ContentTemplate>

                </asp:TabPanel>
            </asp:TabContainer>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="btnupload" />
        </Triggers>
    </asp:UpdatePanel>

推荐答案

请执行以下操作

in your page load method do as below
protected void Page_Load(object sender, EventArgs e)
{
    Page.Form.Attributes.Add("enctype", "multipart/form-data");
    ScriptManager scriptManager = ScriptManager.GetCurrent(this);
    if (scriptManager != null)
    {
        scriptManager.RegisterPostBackControl(btnupload);
    }
}





从aspx页面删除触发器。从后面的代码中做到



remove the Triggers from aspx page. do it from the code behind


这篇关于如何在Update和Tab面板中使用Fileupload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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