Results 1 to 2 of 2

Thread: onclick event/assign value

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    1

    Exclamation onclick event/assign value

    Hi all



    Im trying to assign a value from-------- e.Item.Cells(4).Attributes.Add("onclick", "alert('You click at ID: " & e.Item.Cells(4).Text & "!');")

    to a textbox1.text

    instead of useing the alert metod how can i then assign textbox1. (text / value) = " & e.Item.Cells(4).Text & "


    Sub dgmenukort_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
    If e.Item.ItemType = ListItemType.Item Or _
    e.Item.ItemType = ListItemType.AlternatingItem Then

    e.Item.Cells(4).Style("cursor") = "hand"
    e.Item.Cells(4).Attributes.Add("onclick", "alert('You click at ID: " & e.Item.Cells(0).Text & "!');")

    End Sub

    rgds jens

  2. #2
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Re: onclick event/assign value

    Try something like this:

    VB Code:
    1. e.Item.Cells(4).Style("cursor") = "hand"
    2. e.Item.Cells(4).Attributes.Add("onclick", "javascript:assignValue('textbox1', '" & e.Item.Cells(4).Text & "')")

    Code:
    <script type="text/javascript">
    
    	function assignValue(ID, assignedvalue)
    	{
    		document.getElementByID(ID).value = assignedvalue;
            }
    
    </script>
    Haven't tested it or anything, so not sure if it will work, but its a start

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