2012-12-12 53 views
0

它包含AJAX上傳和文本框和標籤 什麼,我需要做的是 當上傳完成我在文本框中寫去無刷新頁面與ASP.net組件實現Ajax組件

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" 
     onuploadcomplete="AjaxFileUpload1_UploadComplete" /> 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
</div> 
</form> 
</body> 
</html> 

標記這裏是我的C#代碼

protected void AjaxFileUpload1_UploadComplete(object sender,AjaxControlToolkit.AjaxFileUploadEventArgs e) 
{ 
    string path = Server.MapPath("~/nn/") + e.FileName; 
    AjaxFileUpload1.SaveAs(path); 
    Label1.Text = TextBox1.Text; 
} 

的問題是,AJAX控件事件不能覺得.NET組件 任何幫助嗎?

+0

看看這個鏈接。我注意到它使用了一個ThrobberID。 http://forums.asp.net/t/1810838.aspx/1 –

回答

0

我相信你需要將你的代碼包裝在更新面板控件中。

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <asp:ScriptManager ID="ScriptManager1" runat="server"> 
     </asp:ScriptManager> 
     <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
      <ContentTemplate> 
       <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" 
        onuploadcomplete="AjaxFileUpload1_UploadComplete" /> 
       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
       <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
    </div> 
</form> 
</body> 
</html> 
+0

謝謝,但它沒有工作太...問題是,看起來像ajax上傳不能感受.net組件在C#代碼! –