2013-03-26 49 views
0
 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test"%> 

     <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> 

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head runat="server"> 
     <title></title> 
     </head> 
     <body style="height: 162px"> 
<form id="form1" runat="server"> 
<div> 

    <asp:RadioButton ID="MCA" runat="server" Text="MCA" AutoPostBack="True" 
     oncheckedchanged="MCA_CheckedChanged" /> 
    <br /> 

</div> 
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"> 
    <asp:ListItem Value="Sem1"></asp:ListItem> 
    <asp:ListItem Value="Sem2"></asp:ListItem> 
</asp:DropDownList> 
<br /> 
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
    onselectedindexchanged="DropDownList2_SelectedIndexChanged" 
    ViewStateMode="Enabled"> 
    <asp:ListItem Value="MCA101"></asp:ListItem> 
    <asp:ListItem Value="MCA103">MCA103</asp:ListItem> 
</asp:DropDownList> 
<br /> 
<asp:ScriptManager ID="ScriptManager1" runat="server"> 
</asp:ScriptManager> 
<br /> 

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
    <br /> 
     <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" 
      OnUploadComplete="upload"/> 
    <br /> 
    </ContentTemplate> 
</asp:UpdatePanel> 
</form> 
</body> 
</html> 

事件代碼..如何在AjaxFileUpload onuploadComplete事件中獲取選定的dropdownvalue?

 protected void upload(Object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) 
     { 
     string s = DropDownList1.SelectedValue; 
     string t = DropDownList2.SelectedValue; 
     string path= string path = Server.MapPath("~/MCA/" + s + "/" +t+ "/")+e.FileName 
     } 

//兩個S和T得到即使一些其他的價值選擇下拉列表中的第一個值,這就是上傳不按directort結構完成的。

兩個Dropdownlist都有幾個值,並且回發屬性對於這兩個列表均爲true。

如何獲取列表的確切選定值?

+0

發佈您的.aspx頁面代碼 – 2013-03-26 10:26:13

+0

@KPL我貼.aspx代碼 – Vikash 2013-03-26 10:30:40

回答

0

當AjaxFileUpload OnUploadComplete事件被調用時,問題是Request.Form["__VIEWSTATE"] = null

修正了這個問題(C#代碼):在會議在頁面加載

設置下拉選擇。

爲創建文件路徑的
protected void Page_Load(object sender, EventArgs e) 
{ 
if (Request.Form["__VIEWSTATE"] != null) 
    Session["Path"] = "//" + DropDownList1.SelectedValue + "//" + DropDownList2.SelectedValue + "//"; 
} 

使用session值:

protected void upload(Object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) 
{ 
     string path = string.Empty; 
     if (Session["Path"] != null) 
      path = Server.MapPath("~//MCA" + (string)Session["Path"]) + e.FileName; 
} 
+0

沒有變化!仍然該文件正在上傳到MCA \ sem1 \ MCA101 .. 即使MCA103被選中.. – Vikash 2013-03-26 10:59:11

+0

@Aony_Ask更新了我的答案。 – 2013-03-26 12:47:41

0

我相信你將需要下拉列表中添加降同一更新面板上載控制。

相關問題