Showing posts with label gridview. Show all posts
Showing posts with label gridview. Show all posts

Monday, March 26, 2012

Strange doubt javascript:confirm

Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
javascript:confirm('are you sure delete record?') on gridview at
rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
does nothing... but on my machine at HOME, even when I click cancel it
deletes the records... Its a very strange problem because to my knowledge
its a client feature... What can be the problem ? IE versions ?

Thanks!on my work machine works well, but on my home machine doesnt... both are XP
PRO SP 2

"Paulo Roberto" <paulo.roberto@.edt.com.brescreveu na mensagem
news:%23Po%23f0I1HHA.1188@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
javascript:confirm('are you sure delete record?') on gridview at
rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
does nothing... but on my machine at HOME, even when I click cancel it
deletes the records... Its a very strange problem because to my knowledge
its a client feature... What can be the problem ? IE versions ?
>
Thanks!
>


Paulo Roberto wrote:

Quote:

Originally Posted by

Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
javascript:confirm('are you sure delete record?') on gridview at
rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
does nothing... but on my machine at HOME, even when I click cancel it
deletes the records... Its a very strange problem because to my knowledge
its a client feature... What can be the problem ? IE versions ?
>
Thanks!


Don't use the javascript: protocol when you aren't putting the
Javascript in an URL.

The event expects a return value from the code, which is used to
determine if the action should be canceled or not.

So, the correct code is:

OnClientClick="return confirm('are you sure delete record?');"

--
Gran Andersson
_____
http://www.guffa.com
So, the correct code is:

Quote:

Originally Posted by

>
OnClientClick="return confirm('are you sure delete record?');"
>


Gran, my code is the same as yours and works only on my machine at work...
Any suggestion?
"Paulo Roberto" <paulo.roberto@.edt.com.brwrote in message
news:%23Po%23f0I1HHA.1188@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

What can be the problem ? IE versions ?


Incorrect syntax is your problem...

OnClientClick="return confirm('Are you sure you want to delete this
record?');"

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Paulo Roberto wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

>So, the correct code is:
>>
>OnClientClick="return confirm('are you sure delete record?');"
>>


>
>
Gran, my code is the same as yours and works only on my machine at work...
Any suggestion?
>


Have you examined the generated code to see if there are any differences?

--
Gran Andersson
_____
http://www.guffa.com

Strange doubt javascript:confirm

Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
javascript:confirm('are you sure delete record?') on gridview at
rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
does nothing... but on my machine at HOME, even when I click cancel it
deletes the records... Its a very strange problem because to my knowledge
its a client feature... What can be the problem ? IE versions ?
Thanks!on my work machine works well, but on my home machine doesnt... both are XP
PRO SP 2
"Paulo Roberto" <paulo.roberto@.edt.com.br> escreveu na mensagem
news:%23Po%23f0I1HHA.1188@.TK2MSFTNGP04.phx.gbl...
> Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
> java script:confirm('are you sure delete record?') on gridview at
> rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
> does nothing... but on my machine at HOME, even when I click cancel it
> deletes the records... Its a very strange problem because to my knowledge
> its a client feature... What can be the problem ? IE versions ?
> Thanks!
>
Paulo Roberto wrote:
> Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
> java script:confirm('are you sure delete record?') on gridview at
> rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
> does nothing... but on my machine at HOME, even when I click cancel it
> deletes the records... Its a very strange problem because to my knowledge
> its a client feature... What can be the problem ? IE versions ?
> Thanks!
Don't use the java script: protocol when you aren't putting the
Javascript in an URL.
The event expects a return value from the code, which is used to
determine if the action should be canceled or not.
So, the correct code is:
OnClientClick="return confirm('are you sure delete record?');"
Gran Andersson
_____
http://www.guffa.com
> So, the correct code is:
> OnClientClick="return confirm('are you sure delete record?');"
>
Gran, my code is the same as yours and works only on my machine at work...
Any suggestion?
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:%23Po%23f0I1HHA.1188@.TK2MSFTNGP04.phx.gbl...

> What can be the problem ? IE versions ?
Incorrect syntax is your problem...
OnClientClick="return confirm('Are you sure you want to delete this
record?');"
Mark Rae
ASP.NET MVP
http://www.markrae.net
Paulo Roberto wrote:
>
> Gran, my code is the same as yours and works only on my machine at work..
.
> Any suggestion?
>
Have you examined the generated code to see if there are any differences?
Gran Andersson
_____
http://www.guffa.com

Saturday, March 24, 2012

Strange event behavior with check boxes

I've designed a gridview that contains a template field with an
unbound checkbox, allowing the user to select certain rows for further
action.
I am capturing the CheckedChanged event in order to set the grid's
SelectedIndex equal to the row whose check box was checked or
unchecked. However, for some strange reason when I click a checkbox
the CheckedChanged event fires for every checked checkbox in the grid,
from top to bottom. Consequently, the SelectedIndex always ends up
being the last checked row.
Can anyone shed some light on this behavior?
-- HansOn Jul 26, 9:23 pm, Froefel <hansdeschry...@.gmail.com> wrote:
> I've designed a gridview that contains a template field with an
> unbound checkbox, allowing the user to select certain rows for further
> action.
> I am capturing the CheckedChanged event in order to set the grid's
> SelectedIndex equal to the row whose check box was checked or
> unchecked. However, for some strange reason when I click a checkbox
> the CheckedChanged event fires for every checked checkbox in the grid,
> from top to bottom. Consequently, the SelectedIndex always ends up
> being the last checked row.
> Can anyone shed some light on this behavior?
> -- Hans
Hi...
can you please provide some code sample...
Masudur