Hi:
when the user selects the save button (asp control) to intiate a postback, I
would like to pop up a javascript alert box to confirm if he really wants to
save. If he selects no from alert dialog, I would like to cancel the
postback. How do you do this?
Thanks,
Charlie 3 2172
Charlie,
put this javascript function on the client side of your aspx page
<script>
function confirmSubmit() { var sure=confirm("A re you sure you wish to
continue?");
if (sure) return true ; else return false ; }</script>
and call it from the onclick event of your server control for Save say
BtnSave.
You can type it in the tag itself
onclick="return confirmSubmit() ;"
or
in the Page_Load
BtnSave.Attribu tes.Add("onclic k","return confirmSubmit() ;");
Regards,
Marshal Antony http://dotnetmarshal.com
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl... Hi:
when the user selects the save button (asp control) to intiate a
postback, I would like to pop up a javascript alert box to confirm if he really
wants to save. If he selects no from alert dialog, I would like to cancel the postback. How do you do this?
Thanks, Charlie
Thanks! That worked well. However, I was only able to make it work using
add.attributes in server code. I tried adding "onclick="retur n
confirmSubmit() ;" in the HTML tag, but got errors. Is it possible to call a
client script function in HTML tag like an ordinary HTML control? HTML
Intellisense shows an on_click handler for asp button, but can't figure out
how to wire it up.
Charlie
"Marshal Antony" <ma***********@ yahoo.com> wrote in message
news:uc******** ********@tk2msf tngp13.phx.gbl. .. Charlie,
put this javascript function on the client side of your aspx page <script> function confirmSubmit() { var sure=confirm("A re you sure you wish to continue?"); if (sure) return true ; else return false ; }</script>
and call it from the onclick event of your server control for Save
say BtnSave. You can type it in the tag itself onclick="return confirmSubmit() ;" or in the Page_Load BtnSave.Attribu tes.Add("onclic k","return confirmSubmit() ;");
Regards,
Marshal Antony
http://dotnetmarshal.com "Charlie@CB FC" <ch*****@comcas t.net> wrote in message news:OI******** ******@TK2MSFTN GP12.phx.gbl... > Hi: > > when the user selects the save button (asp control) to intiate a postback, I > would like to pop up a javascript alert box to confirm if he really wants to > save. If he selects no from alert dialog, I would like to cancel the > postback. How do you do this? > > Thanks, > Charlie > >
If you make a regular INPUT button (HTML control) and make it
RUNAT="SERVER" you can put that
javascript function call in the tag itself for the event you want.But this
may not be the case with Server controls.
For eg : Imagebutton's OnClick event is meant for the Server side event
handling.
There might be exceptions which I am not sure.
Hope this helps.
Regards
Marshal Antony http://dotnetmarshal.com
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message
news:eC******** ******@TK2MSFTN GP10.phx.gbl... Thanks! That worked well. However, I was only able to make it work
using add.attributes in server code. I tried adding "onclick="retur n confirmSubmit() ;" in the HTML tag, but got errors. Is it possible to
call a client script function in HTML tag like an ordinary HTML control? HTML Intellisense shows an on_click handler for asp button, but can't figure
out how to wire it up.
Charlie
"Marshal Antony" <ma***********@ yahoo.com> wrote in message news:uc******** ********@tk2msf tngp13.phx.gbl. .. Charlie,
put this javascript function on the client side of your aspx
page <script> function confirmSubmit() { var sure=confirm("A re you sure you wish
to continue?"); if (sure) return true ; else return false ; }</script>
and call it from the onclick event of your server control for
Save say BtnSave. You can type it in the tag itself onclick="return confirmSubmit() ;" or in the Page_Load BtnSave.Attribu tes.Add("onclic k","return confirmSubmit() ;");
Regards,
Marshal Antony
http://dotnetmarshal.com "Charlie@CB FC" <ch*****@comcas t.net> wrote in message news:OI******** ******@TK2MSFTN GP12.phx.gbl... > Hi: > > when the user selects the save button (asp control) to intiate a postback, I > would like to pop up a javascript alert box to confirm if he
really wants to > save. If he selects no from alert dialog, I would like to cancel
the > postback. How do you do this? > > Thanks, > Charlie > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Moore |
last post by:
Can an asp.net button that is a server side control call a client side java
function when the button is clicked? If so, please provide
example.....thanks.,
|
by: Jim Hammond |
last post by:
I can get data from a client-side assembly to the server in two manual
steps, but I need to be able to do it in one step.
Step 1:
The user presses the manually coded "Step 1" button, which calls the
JavaScript function.
The function copies the data into a server textbox control.
Step 2:
The user presses the VS generated "Step 2" button, which calls the
|
by: Guadala Harry |
last post by:
Suppose I have a hyperlink that, when clicked, executes a JavaScript
function on the client. Separately I have a button that, when clicked,
causes a post back and executes a server-side function, as in the following:
<a id="HyperLink5" href="javascript:DoSomethingInClient()">Do Something</a>
<asp:Button id="btnSaveChanges" EnableViewState="true"
CommandName="SaveChanges" Visible="true" Width="115" runat="server"
Text="Save...
|
by: Jordan |
last post by:
I'm trying to initiate Postback from client-side script, and here's what I
have that doesn't work: I have an <asp:Button> on the same page named
btnSave that the user can click (its functionality works fine). I want to
call the button's server-side functionality from the client-side script (in
response to things happening in the client other than the user clicking on
the save button).
function DoSomethingInClient()
{
Do Some Stuff Here
|
by: Donal McWeeney |
last post by:
Hi,
Any pointers to manipulating client side validation being performed.
For example I have a custom control that does a postback to the server - and
I dont want validation to be performed when I click this button! This button
executes a js client side function that then triggers the postback. My
thinking was before the postback to turn off the client side validation but
it does not appear obvious how to do this.
| |
by: Jerry Camel |
last post by:
Trying to implement the following:
Users is logging in
They enter theire username and password and click a login button
The page should then display an activity indicator (animated gif) and then
call the server side routine that autheticates the user.
When the page comes back, the activity indicator disappears and any error
messages show up, or the user is taken to the application page if they were
authenticated.
|
by: COHENMARVIN |
last post by:
I am working on an application where the user enters info into a
multiline textbox. The info is Stylesheet tags that he wants web pages
to use. Basically he would be entering a stylesheet into the textbox,
something like:
================
..link_header{color: #FFFFFF; font-size: 9pt; text-decoration:none;
font-family: Arial; font-weight: bold;}
===================
Then he clicks a PREVIEW button, and a new window pops open with a...
|
by: lmttag |
last post by:
Hello.
We're developing an ASP.NET 2.0 (C#) application and we're trying to
AJAX-enable it. We're having problem with a page not showing the page while
a long-running process is executing. So, we're looking for a way to display
the page with a "please wait..." message while the process is running, and
then, when the process is done, update the page with the actual results/page
content.
We have a page that opens another browser/page...
|
by: MAX2006 |
last post by:
Hi,
I am doing some client side javascipt work. I have a handler for
window.onUnload event and within the code; I need to know the name of the
asp.net button caused the postback. How can I do that?
Thank you
Max
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |