how to change a value of a variable defining in code behind via Java Script

Discussion in '.NET' started by dhmplopoka, Oct 20, 2008.

  1. dhmplopoka

    dhmplopoka

    Joined:
    Oct 20, 2008
    Messages:
    1
    I need to change the value declare in aspx.vb via javascript my code is like this

    //// My Custom Image Class /////

    Public Class imageClass Inherits System.Web.UI.WebControls.Image

    Public imageLabel As String = ""

    End Class

    /////// Default.aspx.vb ////////

    Protected Overrides Sub OnInit(ByVal e As EventArgs)

    Dim picture As imageClass = New imageClass

    pholder.Controls.Add(picture)
    /// THIS SHOULD CHANGE VIA JAVASCRIPT///
    picture.imageLabel = "LabelOne"

    picture.Attributes.Add("onclick","Javascript:click1('" & picture.ClientID & "')")

    End Sub

    Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click

    Dim NewImage As imageClass = New imageClass
    For Each con As Control In pholder.Controls
    If TypeOf con Is imageClass Then
    /// SHOW OLD VALUE DECLARE IN ASPX.VB ///
    MsgBox(CType(con, imageClass).imageLabel)
    end if
    Next

    End Sub

    /////// Default.aspx ////////

    <script type="text/javascript" >

    function click1(id1){document.getElementById(id1).setAttribute("imageLabel","Click");}

    </script>

    <html>
    <body>
    <form id="form1" runat="server">

    <asp : PlaceHolder ID="pholder" runat="server" ></asp : PlaceHolder>

    <asp : Button ID="Submit" Text="Submit" runat="server" />
    </form>
    </body>
    </html>


    thanks in advance
     
    dhmplopoka, Oct 20, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    647
    Alphonse Giambrone
    Jun 28, 2003
  2. Marc Castrechini
    Replies:
    3
    Views:
    15,733
    Marc Castrechini
    Jun 23, 2004
  3. keithb
    Replies:
    1
    Views:
    959
    Bruce Barker
    Mar 29, 2006
  4. johny smith
    Replies:
    8
    Views:
    447
    Peter Koch Larsen
    Jul 2, 2004
  5. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    531
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
Loading...

Share This Page