我有这个页面与FileUpload元素.但当我试图在后面的代码中获取值,它总是返回“NULL”值.它只发生在一个页面.其他页面工作完美.似乎是什么问题?我试图搜索,但没有工作.像使用UpdatePanel,触发器,等.
下面是我的代码:
ASPX
<telerik:RadWindow ID="showImportDialog" runat="server" Skin="<%$ appSettings:Skin %>" EnableEmbeddedSkins="false"
Width="350" Height="200" Behaviors="Close" Modal="true" VisibleTitlebar="true" Title="<%$ Resources:Master, Import%>">
<ContentTemplate>
<div class="inputField">
<p style="font-weight: bold; padding-bottom: 3px;"><asp:Literal runat="server" Text="<%$ Resources:Master, SelectImportFileLbl %>" /></p>
<div class="uploadFile">
<span class="glyphicon glyphicon-import"></span>
<span class="filename fontSize13"><asp:Literal runat="server" Text="<%$ Resources:Master, ImportFieldText %>" /></span>
<asp:FileUpload ID="ImportFile" runat="server" CssClass="fontSize13" ClientIDMode="static"/>
</div>
<p id="errorMsg" style="color: #FF0000; font-size:11px; display: none; padding-bottom: 5px; padding-top: 5px;">
<asp:Label ID="Label5" ClientIDMode="static" runat="server" Text=""/>
</p>
</div>
<div id="importGroup" class="delete-confirm-button" style="padding-top: 20px;">
<asp:Button ID="BtnImport" runat="server" AutoPostBack="false" enabled="false"
EnableEmbeddedSkins="false"
Text="<%$ Resources:Master, Import %>" ClientIDMode="static" />
<asp:Button ID="BtnImportCancel" runat="server" AutoPostBack="false" enabled="true"
EnableEmbeddedSkins="false" OnClientClick="btnCancel_Click('showImportDialog'); return false;"
Text="<%$ Resources:Master, Cancel %>" ClientIDMode="static" />
</div>
</ContentTemplate>
</telerik:RadWindow>
字符串
VB
Protected Sub BtnImport_Click(sender As Object, ByVal e As EventArgs) Handles BtnImport.Click
Dim fileName As String = String.Concat(Path.GetFileNameWithoutExtension(ImportFile.PostedFile.FileName), "_", DateTime.Now.ToString("HHmmssff"), ".", Path.GetExtension(ImportFile.PostedFile.FileName))
Dim filePath As String = System.IO.Path.Combine("DataImport", fileName)
Dim fInfo As System.IO.FileInfo = New System.IO.FileInfo(filePath)
fInfo.Directory.Create()
ImportFile.SaveAs(filePath)
End Sub
型
1条答案
按热度按时间m0rkklqb1#
检查你的
Page_Load
方法,我认为控件在那里被重新初始化了。如果你在
Page_Load
中的原始代码是这样的。字符串
然后将其更改为以下内容:
型