简体   繁体   中英

Access control in a number of tags from codebehind

I've such a structure

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:Login ID="LoginControl" runat="server" onauthenticate="LoginControl_Authenticate" >
        <LayoutTemplate>
            <table>
                <tr>
                    <td>
                        <asp:UploadFile ID="upFile"...
                    <td>
                        <asp:Button ID="LoginButton" onclick="LoginButton_Click"...

How get access to FileUpload control in codebehind? If there's no and it's simple eg upFile.FileName But if it's in this tags ther's error:

The name 'upFile' does not exist in the current context

How to change it?

我不知道LayoutTemplate是如何工作的,但你可以试试这个:

FileUpload upFile = (FileUpload)LoginControl.FindControl("upFile");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM