I'm tearing my hair out over this one.
Using VS 2003, inline (not code-behind), vb.net.
I have a button (btnClear) that calls a vb routine that goes into sql server
and truncates a table.
What I want is to call a javascript confirm box upon clicking the button
that asks the user if he's sure he wants to do the deed. I have tried so
many permutations and combinations of RegisterClientScriptBlock, <input
onclick=, runat=server, btnClear.Attributes.Add("onclick",".....") that my
head is spinning.
I just can't seem to get the confirm return value to the vb.net code, the
server-side, or whatever the correct term is. After Googling for help, I
saw many examples of javascript code that is easy to understand and use, but
none that works together with vb.net code.
Can anyone provide a clear method of doing this?
Thanks in advance,
Dave 5 3059
If you add this little JS snippet to your button: onClick="return
confirm('Are you sure you want to delete this report?');".
When the button is clicked, a Yes/No dialog should open. If the user clicks
No, then the script will return false, and nothing should happen. This is
automatic, and you don't need to check for the return value. If they click
Yes, then the button should fire.
"Dave" <da*****************************@stic.net> wrote in message
news:up**************@TK2MSFTNGP15.phx.gbl... I'm tearing my hair out over this one.
Using VS 2003, inline (not code-behind), vb.net.
I have a button (btnClear) that calls a vb routine that goes into sql
server and truncates a table.
What I want is to call a javascript confirm box upon clicking the button that asks the user if he's sure he wants to do the deed. I have tried so many permutations and combinations of RegisterClientScriptBlock, <input onclick=, runat=server, btnClear.Attributes.Add("onclick",".....") that my head is spinning.
I just can't seem to get the confirm return value to the vb.net code, the server-side, or whatever the correct term is. After Googling for help, I saw many examples of javascript code that is easy to understand and use,
but none that works together with vb.net code.
Can anyone provide a clear method of doing this?
Thanks in advance,
Dave
Richard,
Thank you very much for your response. Your answer may be part of the
solution, but I still can't get it to do everything needed. First when you
say "If you add ...", I assume you mean something like this:
<td>
<input OnClick="return confirm('Are you sure you want to delete this
report?');"
type="button" value="Clear" runat="server" id="btnClearVisits">
</td>
I do ge the desired dialog box, but the desired code does not fire. My code
looks something like this:
Sub btnClearVisits(ByVal sender As System.Object, ByVal e As
System.EventArgs)
ClearVisits()
end sub
sub ClearVisits()
[...]
dim sql As String = "TRUNCATE TABLE tblVisits "
Dim NumAffected As Integer = cmd.ExecuteNonQuery()
[...]
end sub
Do you see anything obvious I'm missing or doing wrong? It appears the sub
ClearVisits() never executes. Before I got the idea of confirming with the
user, the sub ClearVisits() worked fine.
Thanks again.
Dave
"Richard Dudley" <ri**@rjdudley.com> wrote in message
news:e9**************@TK2MSFTNGP14.phx.gbl... If you add this little JS snippet to your button: onClick="return confirm('Are you sure you want to delete this report?');".
When the button is clicked, a Yes/No dialog should open. If the user clicks No, then the script will return false, and nothing should happen. This is automatic, and you don't need to check for the return value. If they click Yes, then the button should fire.
"Dave" <da*****************************@stic.net> wrote in message news:up**************@TK2MSFTNGP15.phx.gbl... I'm tearing my hair out over this one.
Using VS 2003, inline (not code-behind), vb.net.
I have a button (btnClear) that calls a vb routine that goes into sql server and truncates a table.
What I want is to call a javascript confirm box upon clicking the button that asks the user if he's sure he wants to do the deed. I have tried so many permutations and combinations of RegisterClientScriptBlock, <input onclick=, runat=server, btnClear.Attributes.Add("onclick",".....") that my head is spinning.
I just can't seem to get the confirm return value to the vb.net code, the server-side, or whatever the correct term is. After Googling for help, I saw many examples of javascript code that is easy to understand and use, but none that works together with vb.net code.
Can anyone provide a clear method of doing this?
Thanks in advance,
Dave
If you want the 'intended' way rather than having to fudge it, have you
considered whether any of the '~Validator' objects will work? Don't know
whether they will suit your purpose but have a look at this link http://aspnet.4guysfromrolla.com/articles/073102-1.aspx
this is Scott Mitchell's website, basically anything I've ever wanted to
know about asp.net I've managed to find there.
alternatively one more code line to try:
<td>
<input OnClick="if(confirm('Are you sure you want to delete this
report?')) btnClearVisits_Click();"
type="button" value="Clear" runat="server" id="btnClearVisits">
</td>
might be way off but then again it might work...
"Dave" wrote: Richard,
Thank you very much for your response. Your answer may be part of the solution, but I still can't get it to do everything needed. First when you say "If you add ...", I assume you mean something like this:
<td> <input OnClick="return confirm('Are you sure you want to delete this report?');" type="button" value="Clear" runat="server" id="btnClearVisits"> </td>
I do ge the desired dialog box, but the desired code does not fire. My code looks something like this:
Sub btnClearVisits(ByVal sender As System.Object, ByVal e As System.EventArgs) ClearVisits() end sub
sub ClearVisits()
[...]
dim sql As String = "TRUNCATE TABLE tblVisits " Dim NumAffected As Integer = cmd.ExecuteNonQuery()
[...] end sub
Do you see anything obvious I'm missing or doing wrong? It appears the sub ClearVisits() never executes. Before I got the idea of confirming with the user, the sub ClearVisits() worked fine.
Thanks again.
Dave
"Richard Dudley" <ri**@rjdudley.com> wrote in message news:e9**************@TK2MSFTNGP14.phx.gbl... If you add this little JS snippet to your button: onClick="return confirm('Are you sure you want to delete this report?');".
When the button is clicked, a Yes/No dialog should open. If the user clicks No, then the script will return false, and nothing should happen. This is automatic, and you don't need to check for the return value. If they click Yes, then the button should fire.
"Dave" <da*****************************@stic.net> wrote in message news:up**************@TK2MSFTNGP15.phx.gbl... I'm tearing my hair out over this one.
Using VS 2003, inline (not code-behind), vb.net.
I have a button (btnClear) that calls a vb routine that goes into sql server and truncates a table.
What I want is to call a javascript confirm box upon clicking the button that asks the user if he's sure he wants to do the deed. I have tried so many permutations and combinations of RegisterClientScriptBlock, <input onclick=, runat=server, btnClear.Attributes.Add("onclick",".....") that my head is spinning.
I just can't seem to get the confirm return value to the vb.net code, the server-side, or whatever the correct term is. After Googling for help, I saw many examples of javascript code that is easy to understand and use, but none that works together with vb.net code.
Can anyone provide a clear method of doing this?
Thanks in advance,
Dave
Thanks, Bonj, that's an interesting idea. I know a little about Validators,
but hadn't thought about using them here. One of my goals is to write more
platform-independent code, and so using a Validator control will be one of
the later solutions I try.
I'm still curious about solving this problem in a straightforward way,
because it will enlighten some concepts for me I need to know as a
programmer, and will be useful for the future. I think the answer is
simple, but you need to know more about the ins and outs of client-server
than I currently know.
Dave
"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com... If you want the 'intended' way rather than having to fudge it, have you considered whether any of the '~Validator' objects will work? Don't know whether they will suit your purpose but have a look at this link http://aspnet.4guysfromrolla.com/articles/073102-1.aspx this is Scott Mitchell's website, basically anything I've ever wanted to know about asp.net I've managed to find there.
alternatively one more code line to try: <td> <input OnClick="if(confirm('Are you sure you want to delete this report?')) btnClearVisits_Click();" type="button" value="Clear" runat="server" id="btnClearVisits"> </td> might be way off but then again it might work...
"Dave" wrote:
Richard,
Thank you very much for your response. Your answer may be part of the solution, but I still can't get it to do everything needed. First when you say "If you add ...", I assume you mean something like this:
<td> <input OnClick="return confirm('Are you sure you want to delete this report?');" type="button" value="Clear" runat="server" id="btnClearVisits"> </td>
I do ge the desired dialog box, but the desired code does not fire. My code looks something like this:
Sub btnClearVisits(ByVal sender As System.Object, ByVal e As System.EventArgs) ClearVisits() end sub
sub ClearVisits()
[...]
dim sql As String = "TRUNCATE TABLE tblVisits " Dim NumAffected As Integer = cmd.ExecuteNonQuery()
[...] end sub
Do you see anything obvious I'm missing or doing wrong? It appears the sub ClearVisits() never executes. Before I got the idea of confirming with the user, the sub ClearVisits() worked fine.
Thanks again.
Dave
"Richard Dudley" <ri**@rjdudley.com> wrote in message news:e9**************@TK2MSFTNGP14.phx.gbl... > If you add this little JS snippet to your button: onClick="return > confirm('Are you sure you want to delete this report?');". > > When the button is clicked, a Yes/No dialog should open. If the user > clicks > No, then the script will return false, and nothing should happen. This > is > automatic, and you don't need to check for the return value. If they > click > Yes, then the button should fire. > > "Dave" <da*****************************@stic.net> wrote in message > news:up**************@TK2MSFTNGP15.phx.gbl... >> I'm tearing my hair out over this one. >> >> Using VS 2003, inline (not code-behind), vb.net. >> >> I have a button (btnClear) that calls a vb routine that goes into sql > server >> and truncates a table. >> >> What I want is to call a javascript confirm box upon clicking the >> button >> that asks the user if he's sure he wants to do the deed. I have tried >> so >> many permutations and combinations of RegisterClientScriptBlock, >> <input >> onclick=, runat=server, btnClear.Attributes.Add("onclick",".....") >> that >> my >> head is spinning. >> >> I just can't seem to get the confirm return value to the vb.net code, >> the >> server-side, or whatever the correct term is. After Googling for >> help, I >> saw many examples of javascript code that is easy to understand and >> use, > but >> none that works together with vb.net code. >> >> Can anyone provide a clear method of doing this? >> >> >> Thanks in advance, >> >> Dave >> >> > >
I added this - btnClearVisits.Attributes.add("OnClick","javascrip t:return
confirm('Are you sure you want to delete this report?');") - to my
Page_Load, removed it from the <input> tag, and it worked great after I
removed some CS101 errors I had put in previously.
I appreciate the responses to my problem.
Dave
"Richard Dudley" <ri**@rjdudley.com> wrote in message
news:e9**************@TK2MSFTNGP14.phx.gbl... If you add this little JS snippet to your button: onClick="return confirm('Are you sure you want to delete this report?');".
When the button is clicked, a Yes/No dialog should open. If the user clicks No, then the script will return false, and nothing should happen. This is automatic, and you don't need to check for the return value. If they click Yes, then the button should fire.
"Dave" <da*****************************@stic.net> wrote in message news:up**************@TK2MSFTNGP15.phx.gbl... I'm tearing my hair out over this one.
Using VS 2003, inline (not code-behind), vb.net.
I have a button (btnClear) that calls a vb routine that goes into sql server and truncates a table.
What I want is to call a javascript confirm box upon clicking the button that asks the user if he's sure he wants to do the deed. I have tried so many permutations and combinations of RegisterClientScriptBlock, <input onclick=, runat=server, btnClear.Attributes.Add("onclick",".....") that my head is spinning.
I just can't seem to get the confirm return value to the vb.net code, the server-side, or whatever the correct term is. After Googling for help, I saw many examples of javascript code that is easy to understand and use, but none that works together with vb.net code.
Can anyone provide a clear method of doing this?
Thanks in advance,
Dave
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kathy Burke |
last post by:
I'm trying to use the following code to use a javascript return confirm.
Cancel would exit the sub and return the page to its history (-2).
OK would proceed with the asp.net code, i.e., run the...
|
by: Chris Fink |
last post by:
My goal is to have an ASP.NET checkbox server tag with it's autopostback set
to true, that when clicked will run the checkbox's CheckedChanged event.
However, I would like to try to add a...
|
by: Tigger |
last post by:
Dear Experts,
I am working on ASP.NET. I have got a problem related to the usage of
Javascript in ASP.NET. Please help. The story is the following:
1) I am developing an ASP.NET application. I...
|
by: tshad |
last post by:
This is from my previous post, but a different issue.
I have the following Javascript routine that opens a popup page, but doesn't
seem to work if called from an asp.net button. It seems to work...
|
by: None |
last post by:
I have a small JavaScript event handler that runs when a Button is clicked.
This function is called before the postback. I would like to prevent the
execution of the postback in that function...
|
by: Keith |
last post by:
I have a web form that contains a repeater control that is designed to ask
like a check book register. Clicking on a certain transaction takes the user
to a different .aspx page where it can be...
|
by: Keith |
last post by:
I have a web form that contains a repeater control that is designed to ask
like a check book register. Clicking on a certain transaction takes the user
to a different .aspx page where it can be...
|
by: bay_dar |
last post by:
Hi, I have an internal ASP.NET application that I'm are using to send
e-mails out based on a single milepost or milepost range entered.
I'm trying to do two things when a user clicks on the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
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...
| |