title: Upload files in vb.net
body: <p>I have a code in vb.net (as shown below) in which it ask to upload a file after the selection of yes button. On checking No button, it doesn't ask us to upload a file as shown below in the images. </p>
  
  <p>************************************************VB Code****************************************************** </p>
  
  <pre><code>    Protected Sub rblOrgChart_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rblOrgChart.SelectedIndexChanged
              ruOrgChart.Visible = False
              hlOrgChart.Visible = False
  
  
              ' btnOrgChart.Visible = rblOrgChart.SelectedValue And bolHasWritePermission
              hlOrgChart.Visible = rblOrgChart.SelectedValue
  
              If CBool(rblOrgChart.SelectedValue) Then
                  ruOrgChart.Visible = True
  
                  Dim dtFile As DataTable
                  dtFile = dalClientProfile.GetFileUpload(CInt(Session("OrgID")), CInt(Session("LicenseeID")), enumFileTypeUpload.ORG_CHART)
                  If dtFile.Rows.Count &gt; 0 Then
                      Dim dr As DataRow = dtFile.Rows(0)
                      hlOrgChart.NavigateUrl = ruOrgChart.TargetFolder &amp; "/" &amp; dr.Item("FileName")
                      hlOrgChart.Text = dr.Item("FileName")
  
                      hlOrgChart.Visible = True
                  End If
              Else
                  ' If Me.lblOrgChartMissing2.Visible Then Me.lblOrgChartMissing2.Visible = False
              End If
  
          End Sub
  </code></pre>
  
  <p>The code inside the method <code>btnOrgChart_Click</code> is:</p>
  
  <pre><code>Protected Sub btnOrgChart_Click(sender As Object, e As System.EventArgs) Handles btnOrgChart.Click
      Try
  
          'If ruOrgChart.InvalidFiles.Count &gt; 0 Then
          '    lblOrgChartNotPDF.Visible = True
          'Else
          '    lblOrgChartNotPDF.Visible = False
          'End If
  
          '------------------------------------------------------------------
          ' Q07. HAS WRITTEN ORG. CHART [IAPData..tblReadinessProfile_Question ID=9 ]
          '------------------------------------------------------------------
  
  
  
          If (rblOrgChart.SelectedValue = 1 And ruOrgChart.UploadedFiles.Count &gt; 0) Then
              hlOrgChart.Visible = True
              '' ''======' BEGIN NEW CODE --- to upload file to virtual directory
              Dim sufile As Telerik.Web.UI.UploadedFile = Nothing
              For Each sufile In Me.ruOrgChart.UploadedFiles
  
                  ' for now upload files on webserver
                  'If AppSettings.Item("Environment") &lt;&gt; "Prod" Then
                  remoteName = Request.PhysicalApplicationPath
                  'Else
                  'remoteName = AppSettings.Item("UploadRootPath").ToString.Trim()
                  'End If
  
                  Dim strPhysicalFilePath As String = remoteName &amp; AppSettings.Item("FileUploadRootPath").ToString &amp; "\" &amp; dtLicensee.Rows(0).Item("UniqueIdentifier").ToString &amp; "\" &amp; dtOrg.Rows(0).Item("OrgCode").ToString &amp; "\"
  
                  CreateFileUploaderLink(remoteName)
  
                  If Not Directory.Exists(strPhysicalFilePath) Then
                      Directory.CreateDirectory(strPhysicalFilePath)
                  End If
  
                  hlOrgChart.NavigateUrl = AppSettings.Item("FileUploadRootPath").ToString &amp; "/" &amp; dtLicensee.Rows(0).Item("UniqueIdentifier").ToString &amp; "/" &amp; dtOrg.Rows(0).Item("OrgCode").ToString &amp; "/" &amp; ruOrgChart.UploadedFiles(0).GetName()
                  dalClientProfile.SaveFileUpload(CInt(Session("OrgID")), CInt(Session("LicenseeID")), enumFileTypeUpload.ORG_CHART, ruOrgChart.UploadedFiles(0).GetName(), strPhysicalFilePath, True)
  
                  hlOrgChart.Text = ruOrgChart.UploadedFiles(0).GetName()
                  Dim NewFileName As String
                  NewFileName = sufile.GetName()
                  'If File.Exists(strPhysicalFilePath &amp; NewFileName) Then
                  '    Dim script As String = "alert('" + Me.GetLocalResourceObject("err.fileuploaded.text") + "');"
                  '    ScriptManager.RegisterStartupScript(ruOrgChart, ruOrgChart.GetType(), "clientscript", script, True)
                  '    Exit Sub
                  'End If
                  sufile.SaveAs(strPhysicalFilePath &amp; NewFileName, True)
  
                  ' Cancel the connection 
                  RemoveFileUploaderLink(remoteName)
              Next
          End If
      Catch ex As Exception
          Dim oErr As New ErrorLog(ex, "Error in btnOrgChart_Click")
          Response.Redirect("~/Error/ErrorPage.aspx?type=Err&amp;ui=" &amp; Request.QueryString("ui"), True)
          Exit Sub
      End Try
  
  End Sub   
  </code></pre>
  
  <p><br></p>
  
  <p>**********************************************Images*******************************************************</p>
  
  <p><a href="https://i.stack.imgur.com/zEREd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zEREd.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bsGre.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bsGre.png" alt="enter image description here"></a></p>
  
  <p>As shown above in the images, on selection of yes it ask us to upload a file. 
  By default, it always remains No as the value of HasOrgChart is always 0.</p>
  
  <pre><code> rblOrgChart.SelectedValue = IIf(CBool(dtOrg.Rows(0).Item("HasOrgChart")), 1, 0)
  </code></pre>
  
  <p><br> </p>
  
  <p>******************************************************HTML*************************************************
  <br><br>
  The .aspx code belonging to the above <code>images</code> and to the above  <code>vb codes</code> are:</p>
  
  <pre><code>&lt;div class="grid-c2"&gt;
     &lt;div&gt;
        &lt;asp:UpdatePanel runat="server" ID="Updatepanel1" UpdateMode="Conditional"&gt;
           &lt;Triggers&gt;
              &lt;asp:AsyncPostBackTrigger controlid="rblOrgChart" EventName="SelectedIndexChanged"/&gt;
           &lt;/Triggers&gt;
           &lt;ContentTemplate&gt;
              &lt;asp:RadioButtonList ID="rblOrgChart" runat="server" AutoPostBack="True"&gt;
                 &lt;asp:ListItem ID="rblOrgChartY"  runat="server" Value="1" Text="Yes (Please upload the organizational chart as a PDF file)"&gt;&lt;/asp:ListItem&gt;
                 &lt;asp:ListItem  ID="rblOrgChartN"  runat="server" Value="0" Text="No" &gt;&lt;/asp:ListItem&gt;
              &lt;/asp:RadioButtonList&gt;
              &lt;div&gt;
                 &lt;br /&gt;          
                 &lt;telerik:RadAsyncUpload ID="ruOrgChart" runat="server" AutoPostBack="true"
                    HideFileInput="True"                                                            
                    AllowedFileExtensions=".pdf"
                    OnClientValidationFailed="validationFailed" 
                    onclientfileuploaded="ruOrgChart_Fileuploaded" 
                    MaxFileInputsCount="1"
                    InitialFileInputsCount="1"
                    MaxFileSize="5000000"
                    /&gt;
                 &lt;div class="fileLink"&gt;
                    &lt;asp:HyperLink runat="server" ID="hlOrgChart" Target="_blank" Visible="false" 
                       Text=""&gt;&lt;/asp:HyperLink&gt;
                 &lt;/div&gt;
              &lt;/div&gt;
              &lt;br /&gt;
              &lt;div style="display:none"&gt;
                 &lt;asp:linkButton ID="btnOrgChart" CssClass="btnUpload" runat="server" Text=""   /&gt;
              &lt;/div&gt;
              &lt;br /&gt;
           &lt;/ContentTemplate&gt;
        &lt;/asp:UpdatePanel&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am wondering what changes do I need to make in the vb.net and .aspx codes so that instead of Yes and No radio button, there is only select button which ask us directly to upload a file with no yes/no options. </p>