Imports System.Web.ui
Imports system.componentmodel
Public Class UploadFile
Inherits System.Web.ui.WebControls.WebControl
'Set the encoding type used by the browser when sending the form of data to the server
The 'Multipart / Form-Data form data is encoded as a message, and the page on the page corresponds to a portion.
Protected Overridable Sub Ensureenctype ()
Dim Parent as system.web.ui.control = me.parent
While Not (PARENT IS NOTHING) Andalso Not (Parent.Gettype is gettype (system.web.ui.htmlcontrols.htmlform)) Andalso Not (Parent.GetType is gettype (system.web.ui.page))
Parent = parent.parent
End while
Dim myform as system.web.ui.htmlcontrols.htmlform = pent
IF not (parent is nothing) THEN
MyForm.Enctype = "Multipart / Form-Data"
END IF
End Sub
'Rewote the Tagkey property. Writing an HTML tagged as Input
Protected overloads overrides readonly property tagkey () as system.Web.ui.htmlTextwritertag
Get
Return HtmlTextWritertag.input
END GET
End Property
'Rewrive the onprender method in custom server control,
'When requesting custom controls from an ASP.NET page, the onprender method is called on the prerender phase of the page (when the server control will be present to the PAGE object included).
Protected Overloads Overrides Sub onprender (Byval E AS System.EventArgs)
Mybase.onprender (e)
If not (me.page is nothing) then 'If the page is actually available
ME.ensureEnctype ()
END IF
End Sub
Protected Overloads Overides Sub Render (Byval Writer As System.Web.ui.htmlTextwriter)
IF not (me.page is nothing "
Me.page.verifyrenderingInServerForm (me) 'confirms that the ASP.NET server control specified for the runtime is included in the HTMLFORM server control (