473,466 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

checkBox and client confirm

I'm using asp.net 2.0

I have a checkbox with server checkedCanged event .
I must add a confirm on click event.
I have used this : myCheckBox.Attributes.Add("onClick", "return
CofirmFunction()"); on Page_Load event.

On page : <script type="text/javascript" language="javascript">
function CofirmFunction()
{
var test = confirm('message ?');
if (test) {return true;}
else {return false;}
}
</script>

The problem is that the myCheckBox_checkedCanged event don't work.

Can I solve the problem ?
Apr 11 '06 #1
3 5554
enzo wrote:
I'm using asp.net 2.0

I have a checkbox with server checkedCanged event .
I must add a confirm on click event.
I have used this : myCheckBox.Attributes.Add("onClick", "return
CofirmFunction()"); on Page_Load event.

On page : <script type="text/javascript" language="javascript">
function CofirmFunction()
{
var test = confirm('message ?');
if (test) {return true;}
else {return false;}
}
</script>

The problem is that the myCheckBox_checkedCanged event don't work.

Can I solve the problem ?


You sure about the spelling?

CofirmFunction() not ConfirmFunction(). Just in case you've misspelt it
in one location.

Also, this can be shortened to:

function ConfirmFunction()
{
return confirm('message ?');
}
or even

myCheckBox.Attributes.Add("onclick", " return confirm('message ?');");

And make sure it only adds the attribute on the first page load and not
on postbacks.
Apr 11 '06 #2
thanks for reply,
You sure about the spelling? Yes my source code is correct

the client confirm message works
Afetr confirm response (OK / Cancel)
also if I click on OK button, the server myCheckBox_checkedCanged event
don't work.
If I comment myCheckBox.Attributes.Add("onClick", "return
ConfirmFunction()");
the myCheckBox_checkedCanged work.
"Ray Booysen" wrote:
enzo wrote:
I'm using asp.net 2.0

I have a checkbox with server checkedCanged event .
I must add a confirm on click event.
I have used this : myCheckBox.Attributes.Add("onClick", "return
CofirmFunction()"); on Page_Load event.

On page : <script type="text/javascript" language="javascript">
function CofirmFunction()
{
var test = confirm('message ?');
if (test) {return true;}
else {return false;}
}
</script>

The problem is that the myCheckBox_checkedCanged event don't work.

Can I solve the problem ?


You sure about the spelling?

CofirmFunction() not ConfirmFunction(). Just in case you've misspelt it
in one location.

Also, this can be shortened to:

function ConfirmFunction()
{
return confirm('message ?');
}
or even

myCheckBox.Attributes.Add("onclick", " return confirm('message ?');");

And make sure it only adds the attribute on the first page load and not
on postbacks.

Apr 11 '06 #3
if you view source, you will see your client onclick look something like:

onclick="return ConfirmFunction(); __doPostback('myCheckBox','')"

so you can see no matter what the function returns, the postback is not
done.

try:

myCheckBox.Attributes.Add("onClick",
"if (!ConfirmFunction()) return; else "
+ GetPostBackClientEvent(myCheckBox,"") + ";");

-- bruce (sqlwork.com)

"enzo" <en**@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
thanks for reply,
You sure about the spelling?

Yes my source code is correct

the client confirm message works
Afetr confirm response (OK / Cancel)
also if I click on OK button, the server myCheckBox_checkedCanged event
don't work.
If I comment myCheckBox.Attributes.Add("onClick", "return
ConfirmFunction()");
the myCheckBox_checkedCanged work.
"Ray Booysen" wrote:
enzo wrote:
> I'm using asp.net 2.0
>
> I have a checkbox with server checkedCanged event .
> I must add a confirm on click event.
> I have used this : myCheckBox.Attributes.Add("onClick", "return
> CofirmFunction()"); on Page_Load event.
>
> On page : <script type="text/javascript" language="javascript">
> function CofirmFunction()
> {
> var test = confirm('message ?');
> if (test) {return true;}
> else {return false;}
> }
> </script>
>
> The problem is that the myCheckBox_checkedCanged event don't work.
>
> Can I solve the problem ?


You sure about the spelling?

CofirmFunction() not ConfirmFunction(). Just in case you've misspelt it
in one location.

Also, this can be shortened to:

function ConfirmFunction()
{
return confirm('message ?');
}
or even

myCheckBox.Attributes.Add("onclick", " return confirm('message ?');");

And make sure it only adds the attribute on the first page load and not
on postbacks.

Apr 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dennis Allen | last post by:
Hi. I got a checkbox in a form. When the form is submitted, an email is generated. In the email text is the field name: on or off. The client doesn't want to see on or off, but yes or no. ...
2
by: Homa | last post by:
Hi, I have a Datagrid that uses as a shopping cart and have a checkbox template column in it. I can't add both OnCheckedChanged Event and onclick client script for it. I want to do two...
2
by: Irfan Akram | last post by:
Hi Guys, I have these series of checkboxes. Whenever any of them are unchecked, I want to display a warning, asking the user to confirm if he really wants to do that. I have added an attribute,...
0
by: enzo | last post by:
Hi, I have a server checkbox with a "OnCheckedChanged" event. It's works. Then I have add a client confirmation : myCheckBox.Attributes.Add("onClick","javascript:return confirm('mymessage');"); ...
4
by: tshad | last post by:
I use popups periodically to my buttons to prevent actions in my pages. When I tried this with a checkbox: DeclineSSN.Attributes.Add("onClick", "if(!confirm('Declining to enter SSN will...
1
by: pleaseexplaintome | last post by:
I have a datagrid with checkboxes and I can check/uncheck the checkboxes to update a database by calling my oncheckchanged function. I would like to add popup asking the users if they are sure...
4
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Is there a cancel argument for cancelling if you want to check or uncheck a checkbox? In the checkChanged event of a checkbox I ask the user if they are sure they want to check/uncheck...
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
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
Oralloy
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,...
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...
1
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...
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.