|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Converting javascript to vbscript
I am trying to convert a javascript I'm using into a vbscript, unfortunately I don't know very much about either to make it possible. If anyone has any suggestions that would be lovely.
Here's the javascript: Code:
<script language="javascript">
function confirm_delete() {
if (confirm("Are you sure you want to delete this item?")==true)
return true;
return false; }
</script>
and I'm using a ItemCreated function to pick it up in ASP: Code:
Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As DataGridItemEventArgs)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem
Dim myTableCell As TableCell
myTableCell = e.Item.Cells(6)
Dim myDeleteButton As LinkButton
myDeleteButton = myTableCell.Controls(0)
myDeleteButton.Attributes.Add("onclick", "return confirm_delete();")
End Select
End Sub
|
|
#2
|
||||
|
||||
|
in VBScript
Code:
Function confirm_delete()
If(confirm("Are you sure you want to delete this item?") = true) Then
value = true
Else
value = false
End If
confirm_delete = value
End Function
|
|
#3
|
|||
|
|||
|
Thanks, I actually wrote something close to that myself, so I know I'm on the right track. The next step is this function:
Code:
Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As DataGridItemEventArgs)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem
Dim myTableCell As TableCell
myTableCell = e.Item.Cells(6)
Dim myDeleteButton As LinkButton
myDeleteButton = myTableCell.Controls(0)
myDeleteButton.Attributes.Add("onclick", "vbscript:confirm_delete();")
End Select
End Sub
(I changed the line: ("onclick", "return confirm_delete();") to: ("onclick", "vbscript:confirm_delete();") Now, the message box comes up, but I'm not getting a return value of true or false. (By that I mean when you click Yes or No, it deletes the item regardless of the selection) Any other ideas? Thanks for your help already ![]() |
|
#4
|
||||
|
||||
|
If you are doing this client-side you should keep it in JavaScript, and not do it in VBScript.
|
|
#5
|
|||
|
|||
|
hehe actually I agree with you. I'm not even sure if it'll work in vbscript at all... My boss just has something against javascripts for some reason. But after getting him to take a look at it, he seems to think it should stay as a javascript this time (As in, we couldn't get the vbscript one to work
)Thanks for your advice |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Converting javascript to vbscript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|