www.webdeveloper.com
Results 1 to 7 of 7

Thread: Open an image with javascript at asp.net

  1. #1
    Join Date
    May 2006
    Posts
    9

    Open an image with javascript at asp.net

    Hi!

    I want to use the value of a Label(Label1), that as the path of an image, to make it as an argument of the funtion P_OpenWindow...
    But this is not working...
    Can anyone help me?

    I have a file.aspx with the code:

    <SCRIPT>
    function P_OpenWindow(pURL,pName,pFeatures){
    window.open(pURL,pName,pFeatures)
    }
    </SCRIPT>

    and I got the file.aspx.vb, on the Page_Load I've the code below:

    btn_item2.Attributes.Add("onclick",
    "javascript:P_OpenWindow(document.getElementById('" & Me.Label1.ClientId &
    "').value,'','width=819,height=518');")

    But is not working...

    On the window's properties that is open, shows the Address(URL):
    http://localhost/Projecto1/undefined

    the 'undefined' means that the value is not being read!

    What can I do?

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by André Vitorino
    What can I do?
    Post the URL.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    May 2006
    Posts
    9
    Sorry I do not understand what you mean...

  4. #4
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    A label does not have a value on the client, did you want to use innerHTML?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint] | twitter | linkedin | http://www.pascarello.com

  5. #5
    Join Date
    May 2006
    Posts
    9
    Yes it can be...
    I just want that my project open an image...

    Would you tell me how can I do with the innerHTML?

    Thanks

  6. #6
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    If you would post the URL of your page so that we could see what on Earth it is that you are up to.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  7. #7
    Join Date
    May 2006
    Posts
    9
    My page is not already online...I do not have access to the server...but I can give you my code....

    file.aspx
    <SCRIPT>
    function P_OpenWindow(pURL,pName,pFeatures){
    window.open(pURL,pName,pFeatures)
    document.write("<b> " + pURL + " </b>")
    }
    </SCRIPT>


    file.aspx.vb

    Dim scmdIM As New System.Data.SqlClient.SqlCommand
    scmdIM.Connection = New System.Data.SqlClient.SqlConnection(strConn)
    scmdIM.Connection.Open()
    With scmdIM
    .CommandText = "SELECT imagem FROM Modulos " + _
    "WHERE produto = @num and ordem= @ordem"
    .Parameters.Add(New System.Data.SqlClient.SqlParameter("@num", ide))
    .Parameters.Add(New System.Data.SqlClient.SqlParameter("@ordem", i))
    .Connection = scmdIM.Connection
    End With

    Dim drIM As SqlDataReader = scmdIM.ExecuteReader(CommandBehavior.CloseConnection)
    While drIM.Read


    If Not IsDBNull(drIM.Item("imagem")) Then

    If drIM.Item("imagem") <> "" Then
    Dim im As String
    im = drIM.Item("imagem")
    Me.Label1.Text = drIM.Item("imagem")
    img_item2.Attributes.Add("onclick", "javascript:P_OpenWindow2(document.getElementById('" & Me.Label1.ClientID & "').value,'','width=819,height=518');")
    end if
    end if
    end while

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles