Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding Button until called upon.

Status
Not open for further replies.

Anthony904

IS-IT--Management
Jul 15, 2004
153
US
I have a form that a user can browse and upload a file (excel) to the server. Once the the file is uploaded, the user hits a button that transfer the data into access.

My problem is .. The upload form currently displays the "transfer" button on startup. I would like for this to be displayed after the file has been uploaded.

Any Ideas? Thanks!

This is the upload sub...
Code:
      Sub Upload_Click(Sender as Object, e as EventArgs)

         ' Display properties of the uploaded file

         FileName.InnerHtml = MyFile.PostedFile.FileName
         FileContent.InnerHtml = MyFile.PostedFile.ContentType 
         FileSize.InnerHtml = MyFile.PostedFile.ContentLength
         UploadDetails.visible = True
' Let us recover only the file name from its fully qualified path at client 

        Dim strFileName as string
        strFileName = MyFile.PostedFile.FileName
        Dim c as string = System.IO.Path.GetFileName(strFileName) ' only the attched file name not its path

                 ' Let us Save uploaded file to server at C:\ServerFolder\


                 Try 

            MyFile.PostedFile.SaveAs("C:\ServerFolder\" + c)
                        Span1.InnerHtml = "Your File Uploaded Sucessfully as:  C:\ServerFolder\" & c
               Span3.InnerHtml = "Thank you! Click TRANSFER to import to access."

                catch Exp as exception
                  span1.InnerHtml = "An Error occured. Please check the attached  file"
                        UploadDetails.visible = false
                            span2.visible=false
               span3.visible=false
                End Try
 
      End Sub
This is where the button currently resides...
Code:
  <Body>

         <Font Color="DarkGreen" Face=Helvetica Size=5> <B>Upload
         </Font>
          <HR Size="2" Color=Black >
          <P>   
          <Form Method="Post"  EncType="Multipart/Form-Data" RunAt="Server">
         Choose Your File  To Upload : <BR>
         <Input ID="MyFile" Type="File" RunAt="Server" Size="40"> <BR>
         <BR>
         <Input Type="Submit" Value="Upload" OnServerclick="Upload_Click" RunAt="Server">
         <Div ID="UploadDetails" Visible="False" RunAt="Server">
            File Name: <Span ID="FileName" RunAt="Server"/> <BR>
            File Content: <Span ID="FileContent" RunAt="Server"/> 

           <BR>
            File Size: <Span ID="FileSize" RunAt="Server"/>bytes
           <BR></Div>
           <Span ID="Span1" Style="Color:Red" RunAt="Server"/>
           <Span ID="Span2" Style="Color:Red" RunAt="Server"/>
        <br><br><Span ID="Span3" Style="Color:Blue" RunAt="Server"/>
         [COLOR=red]<Input Type="submit" Value="Transfer" OnServerclick="Signout_Click" RunAt="Server">[/color red]
      </Form>
   </Body>
 
Set it's Visible property to False to start with and then to True when it is needed.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Oh, and either give it an ID or use a server Button control rather than a HTML input control.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ok...

I've added the code below to retrieve the hidden button.

Code:
MyFile.PostedFile.SaveAs("\\sars6\sabine$\aspx\ip21\sabine\" + c)

Span1.InnerHtml = "Your File Uploaded Sucessfully as:  ip21\sabine\" & c
Span3.InnerHtml = "Thank you! Click TRANSFER to import to access."
[COLOR=red]BtnTransfer.visible=true[/color]

This section hides the button

Code:
<asp:Button id="BtnTransfer" text="Transfer" OnServerclick="Signout_Click" visible="False" runat="server" />

Now my "Transfer" button is not retrieving my Signout_Click Sub.

Code:
Sub Signout_Click(Sender as Object, e as EventArgs) 

FormsAuthentication.SignOut()
Response.Write("<script>window.open('[URL unfurl="true"]http://www.mypage.com/aspx/signout.asp','null','height=500,width=500,status=no,toolbar=no,menubar=no,location=no','_top');<"[/URL] & chr(47) & "script>") 
End Sub

Thanks for helping!
 
Looks like when I took out "asp" in
Code:
<asp:Button id="BtnTransfer" text="Transfer" OnServerclick="Signout_Click" visible="False" runat="server" />

New to .NET as you probably can tell... but
Any ideas why?

Everything else seems to work fine now.. THANKS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top