CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    Posts
    160

    Having trouble with response.write

    I would like to show a pdf file when a user clicks on an image control. I am using the reponse.write comand. It used to work ( I thought) but does not now. I am using vb.net. Here is the sub.

    Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

    Response.Write("<script language=javascript>window.open('pdf files/Certificate and Scope.pdf');</script>")

    End Sub

    Can anyone tell me what is wrong? Thanks,

    Jason

  2. #2
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Having trouble with response.write

    Its because of the /> in the end of the script tag. You can either put this in a seperate response.write statement or i think its a better way if you add it in using this:

    Code:
    ImageButton1.Attributes.Add("onclick", "javascript:window.open('pdf files/Certificate and Scope.pdf');")
    put it in your Load routine
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  3. #3
    Join Date
    Sep 2001
    Posts
    160

    Re: Having trouble with response.write

    Thank you, that worked great. is it possible to do this with the dropdownlist box when the user clicks on a list item. I would like to show the contents of a folder on the web page and then when a user selects a pdf file i would then like to diplay the file. I am new to asp.net and vb.net so I am still learning. Things are a little easier for me in VB6. I am able to get the contents of the folder into a dropdownlist box at this point. I am still having trouble with the Path to the folder where the pdf files are because fo the project name, don't know if it will work on the server or not. Does anyone have any ideas or examples to help.

    Thanks,

    Jason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured