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

Joined
Oct 20, 2008
Messages
1
Reaction score
0
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top