Quantcast
Viewing all articles
Browse latest Browse all 3527

How to Return Value from Javascripts to VB? Hidden Field? I tried but fail.

Hi,

I got a Gridview with Delete function in each row. When user press "Delete", I want to pop-up a message box to let user to choose yes (delete) or no (not delete).

I know the msgbox function does not work. I try to write Javascript in Gridview-RowCommand event:

If e.CommandName = "Delete" Then
            Dim msg As String
            msg = "<script language='javascript'>"
            msg += "if(window.confirm('Are you sure to Delete?')!=true) {document.getElementById('HiddenField2').value = 0;} else {document.getElementById('HiddenField2').value = 1 ;} ;"
            msg += "</script>"
            Response.Write(msg)
End If

I want to use a hidden field (<input id="HiddenField2" type="hidden" runat="server" title="hiiiiiiiiiiiiiii" width="100" />) to store the value return. But when I try to assign a value to the hidden field, I got an error msg:

"Unable to set property 'value' of undefined or null reference".

Does it mean the hidden field I try to assign is invalid?

I really need your help.

Thanks,

Eric


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>