c# - How to get selected dropdownvalue in AjaxFileUpload onuploadComplete event? -
<%@ 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>
event code..
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 }
//both s , t first value of dropdownlist if other value selected , that's uploading not done per directort structure.
both dropdownlist have several values , postback property true both list.
how exact selected value of list ?
issue request.form["__viewstate"] = null
when ajaxfileupload onuploadcomplete event called.
fix issue (c# code):
set dropdown selection in session @ page load.
protected void page_load(object sender, eventargs e) { if (request.form["__viewstate"] != null) session["path"] = "//" + dropdownlist1.selectedvalue + "//" + dropdownlist2.selectedvalue + "//"; }
use session value creation of filepath:
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; }
Comments
Post a Comment