Please Help...Javascript with asp.net

I

Irfan Akram

Hi People,

I have got a simple question to ask. I am trying to build dynamic controls
in asp.net. I have managed to build them successfully. I have also managed to
add the event handlers to all controls I want to monitor. I have the
following code line: -

((CheckBox)ctl).Attributes["onclick"] =
"if(!this.checked){input_box=confirm('All changes to Test will be lost');}";

This is just enabling an action on the check box to be monitored. A
confirmation box props up. Now what I want to do is that if the user selects
ok only then I want to perform the action, but if he presses cancel, then I
do not want to do anything at all. Using this "onclick" thing how can I check
to see what the user selected. Presently it performs the action even if the
user selects cancel.

I hope you guys can help me out.

Much Thanks,

Irfan
 
C

CMA

Hi Irfan,

call to a function from this place like
((CheckBox)ctl).Attributes["onclick"] =
"confirmthis(this.checked)";

and include the function in the page (html view)

<script...>
function confirmthis(var done)
{
if(done='true')
{
return;
}
else
{
return false;
}
}

</script>

"return false" is the line important to your question.
// adjust the code to suit to your problem please.
hope this helps...

regards,
CMA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top