Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to change a value of a variable defining in code behind via Java Script

Reply
Thread Tools

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

 
 
dhmplopoka dhmplopoka is offline
Junior Member
Join Date: Oct 2008
Posts: 1
 
      10-20-2008
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:click 1('" & 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).setAttrib ute("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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb ASP .Net 1 03-29-2006 01:00 AM
defining or not defining destructors johny smith C++ 8 07-02-2004 08:51 AM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments