onclick event/assign value
Hi all :cry:
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
Re: onclick event/assign value
Try something like this:
VB Code:
e.Item.Cells(4).Style("cursor") = "hand"
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 :ehh: