I have 3 Views inside Multi-view and on second view I have FileUpload Control . I am submitting all values on third view on button_click. the problem is when i click the submit button fileuplode.HasFiles is always showing false, I know its showing false because File Upload control is not visible on Webpage. But is there any way to get the posted file details from Fileupload control which is on view 2 and submit that value on view 3..
Here Is the code of View2
<div class="form-group">
<label for="InputMessage">Written Note From Doctor (Approval Note)</label>
<div class="input-group">
<asp:FileUpload runat="server" ID="drFileUpload" placeholder="Doctor Note" class="fileupload" />
</div>
</div>
<asp:Button runat="server" CssClass="btn btn-success" Text="Previous" ID="Button1" OnClick="activeView0" />
<asp:Button runat="server" CssClass="btn btn-success" ID="txtnext2" Text="Next" OnClick="activeView2" ValidationGroup="view2" TabIndex="1" />
And on View 3 i am submitting all the values
Here is the code of Button_click on view3
`
if (drFileUpload.HasFiles)
{
string filename = drFileUpload.PostedFile.FileName;
string extention = Path.GetExtension(filename);
if (extention.ToLower() == ".jpg" | extention.ToLower().ToLower() == ".png" | extention.ToLower().ToLower() == ".jpeg")
{
filename = txtMobile.Text;
int width=Convert.ToInt32(ConfigurationManager.AppSettings["ProfilePicWidth"]);
string Destination = Convert.ToString(Server.MapPath("../Images/Members/" + filename + extention));
CommanFunctions.ResizeImage(width, drFileUpload.PostedFile.InputStream, Destination);
regi.ProfilePic = Destination;
}
else
{
lblError.Text = "Please Upload a valid Image";
multiview.ActiveViewIndex = 1;
}
}
else
{
regi.ProfilePic = null;
}
I tried to Wrap up code in Update Panel but it is not working.
i have found solution myself , as i am storing the file as
HttpPostedFile
on session while changing the viewAnd on Submit I am retrieving that
HttpPostedFile
Hope This will help someone in future