<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="PDFRequesting.WebForm2" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <ajaxToolkit:AsyncFileUpload ID="AsyncFileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Button" /> </div> </form> </body> </html>
Imports AjaxControlToolkit Public Class WebForm2 Inherits System.Web.UI.Page Dim VerifyError As Boolean Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'If first time page is submitted and we have file in FileUpload control but not in session ' Store the values to SEssion Object If ((Session("FileUpload23") Is Nothing) AndAlso AsyncFileUpload1.HasFile) Then Session("FileUpload23") = AsyncFileUpload1 Label1.Text = AsyncFileUpload1.FileName ' Next time submit and Session has values but FileUpload is Blank ' Return the values from session to FileUpload ElseIf ((Not (Session("FileUpload23")) Is Nothing) AndAlso Not AsyncFileUpload1.HasFile) Then AsyncFileUpload1 = CType(Session("FileUpload23"), AsyncFileUpload) Label1.Text = AsyncFileUpload1.FileName ' Now there could be another sictution when Session has File but user want to change the file ' In this case we have to change the file in session object ElseIf AsyncFileUpload1.HasFile Then Session("FileUpload23") = AsyncFileUpload1 Label1.Text = AsyncFileUpload1.FileName End If End Sub Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If Verify() Then Else Label1.Text = "Error" AsyncFileUpload1 = Session("FileUpload23") End If End Sub Protected Function Verify() As Boolean Verify = True If TextBox1.Text = Nothing Then Verify = False End If Return Verify End Function End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)