By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,991 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,991 IT Pros & Developers. It's quick & easy.

Calling Javascript from a vb.net Method - Confirm()

P: n/a
I have an asp button on my form. If user clicks the button then my
Javascript code Confirm pops up with "Ok" & "Cancel" button. If the
user clicks "Ok" from my pop-up then I do my vbMethod doApproveIt().
This works great if the Javascript returns true and I show the message
that the record is approved.

But if the user does not select "OK", chooses "cancel" button then
doApproveIt() method never executes. What I want is, how can I get the
RESPONSE of the user (either true or false) in a variable and
accordingly I want to show message to the user. Now I can not show any
message if the user chooses "cancel", since my method is not executed.
If I remove the return from the Confirm() method, doApproveIt() vb
method executes whteher user presses "OK" or "Cancel", But I need to
check the response in my vb method (what the user pressed), What do I
check to see the response, please provide me some sample code if
possible.

Thank you.

Sahoo J

Here is the code I have in my program:
<asp:button id="btnApprove" onclick="doApproveIt" runat="server"
Height="56px" Width="172px"
ForeColor="#C00000" Font-Size="Large" Font-Bold="True"
Text="Approve"></asp:button>
// The following code is in my pageLoad event.

btnApprove.Attributes("OnClick") = "return confirm('Are you sure, you
want to Approve this Record?');"

// VB Code
Sub doApproveIt(ByVal Source As Object, ByVal E As EventArgs) ' this
executes if value is TRUE , user confirms delete
createApproval("1") ' Approve was selected
' what do I check to see if the user has pressed CANCEL button, I need
to show msg
End Sub
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I simple way to store the response on client and have it on server is to use
a simple <input type=hidden id=response name=response> tag.

On client you can access to the value of this tag with
document.all['response'].value and set it.
On server (VB.NET) you can use Request.Form("response") for retrieve the
response value!

I hope this can help you!

Brun
"J Sahoo" <sa***@mississippi.org> wrote in message
news:24*************************@posting.google.co m...
I have an asp button on my form. If user clicks the button then my
Javascript code Confirm pops up with "Ok" & "Cancel" button. If the
user clicks "Ok" from my pop-up then I do my vbMethod doApproveIt().
This works great if the Javascript returns true and I show the message
that the record is approved.

But if the user does not select "OK", chooses "cancel" button then
doApproveIt() method never executes. What I want is, how can I get the
RESPONSE of the user (either true or false) in a variable and
accordingly I want to show message to the user. Now I can not show any
message if the user chooses "cancel", since my method is not executed.
If I remove the return from the Confirm() method, doApproveIt() vb
method executes whteher user presses "OK" or "Cancel", But I need to
check the response in my vb method (what the user pressed), What do I
check to see the response, please provide me some sample code if
possible.

Thank you.

Sahoo J

Here is the code I have in my program:
<asp:button id="btnApprove" onclick="doApproveIt" runat="server"
Height="56px" Width="172px"
ForeColor="#C00000" Font-Size="Large" Font-Bold="True"
Text="Approve"></asp:button>
// The following code is in my pageLoad event.

btnApprove.Attributes("OnClick") = "return confirm('Are you sure, you
want to Approve this Record?');"

// VB Code
Sub doApproveIt(ByVal Source As Object, ByVal E As EventArgs) ' this
executes if value is TRUE , user confirms delete
createApproval("1") ' Approve was selected
' what do I check to see if the user has pressed CANCEL button, I need
to show msg
End Sub

Nov 18 '05 #2

P: n/a
Thank you Mr. Bruno. It works great with the hidden field.

Sahoo J
"Bruno Sirianni" <br***********@virgilio.it> wrote in message news:<GO**********************@news3.tin.it>...
I simple way to store the response on client and have it on server is to use
a simple <input type=hidden id=response name=response> tag.

On client you can access to the value of this tag with
document.all['response'].value and set it.
On server (VB.NET) you can use Request.Form("response") for retrieve the
response value!

I hope this can help you!

Brun
"J Sahoo" <sa***@mississippi.org> wrote in message
news:24*************************@posting.google.co m...
I have an asp button on my form. If user clicks the button then my
Javascript code Confirm pops up with "Ok" & "Cancel" button. If the
user clicks "Ok" from my pop-up then I do my vbMethod doApproveIt().
This works great if the Javascript returns true and I show the message
that the record is approved.

But if the user does not select "OK", chooses "cancel" button then
doApproveIt() method never executes. What I want is, how can I get the
RESPONSE of the user (either true or false) in a variable and
accordingly I want to show message to the user. Now I can not show any
message if the user chooses "cancel", since my method is not executed.
If I remove the return from the Confirm() method, doApproveIt() vb
method executes whteher user presses "OK" or "Cancel", But I need to
check the response in my vb method (what the user pressed), What do I
check to see the response, please provide me some sample code if
possible.

Thank you.

Sahoo J

Here is the code I have in my program:
<asp:button id="btnApprove" onclick="doApproveIt" runat="server"
Height="56px" Width="172px"
ForeColor="#C00000" Font-Size="Large" Font-Bold="True"
Text="Approve"></asp:button>
// The following code is in my pageLoad event.

btnApprove.Attributes("OnClick") = "return confirm('Are you sure, you
want to Approve this Record?');"

// VB Code
Sub doApproveIt(ByVal Source As Object, ByVal E As EventArgs) ' this
executes if value is TRUE , user confirms delete
createApproval("1") ' Approve was selected
' what do I check to see if the user has pressed CANCEL button, I need
to show msg
End Sub

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.