2012-04-21 46 views
2
aspx: 

<asp:UpdatePanel ID="updtEmpMaster" runat="server"> 
<ContentTemplate> 

<asp:FileUpload ID="tPhoto" Height="23px" runat="server" /> 
<asp:Button ID="Button1" CssClass="btnImage" runat="server" Text="OK" 
onclick="Button1_Click" /> 

</ContentTemplate> 
</asp:UpdatePanel> 


aspx.cs: 

protected void Button1_Click(object sender, EventArgs e) 
{ 
    if (tPhoto.HasFile) 
    { 
    …………………..; 
    } 
    else 
    { 
     …………………..; 
    } 
} 

這裏即使條件失敗後,即使上傳圖像文件。使用沒有UpdatePanel時沒有問題。當前場景中也需要UpdatePanel。任何方式我可以與UpdatePanel解決方案。任何幫助將不勝感激。提前:)無法在更新面板中找到上傳的文件

+0

看這個頁面http://stackoverflow.com/questions/11894132/auto-change-keyboard-語言使用的JavaScript不工作沒有,即 – Learning 2012-09-06 11:55:20

回答

1

由於按照鏈接http://forums.asp.net/p/1105208/1689084.aspx

這個問題在一定程度上有據可查的,更新面板被列爲不具有一定的控制工作。

文件上傳,樹視圖是2個biggies。

在任何情況下,一種解決方案可以用代碼項目:

http://www.codeproject.com/useritems/simpleajaxupload.asp

,如果你看看周圍的論壇和谷歌,你可以,如果你有興趣瞭解更多關於這個問題,但代碼項目解決方案應該讓你開始。

+1

謝謝@Imran得到了很多東西來學習....... :) – 2012-04-23 07:01:19

3

應用此行代碼來解決問題,找到fileuploader到更新面板:

protected void Page_Load(object sender, EventArgs e) 
{ 
    Page.Form.Attributes.Add("enctype", "multipart/form-data"); 
} 
相關問題