473,432 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

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

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
2 6579
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve W | last post by:
I'm running codebehind pages -and this seems to be a hot question when I google it- so, I want to throw up a javascript confirm box before the user commits some SQL updates, and if it evals to true...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
4
by: Mori | last post by:
I would like to be able to call methodTrue() when the user clicks yes and methodFalse() when they click No. How do i accomplish that? here is my code: private void methodTrue() { //method...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.