Thursday, March 22, 2012
suppressing Submit command with a Delete button
confirming whether the user wishes to really delete the item or not.
The confirm pops up, but I cannot suppress the submission when selecting
Cancel.
Heres what I have so far:
' adding the javascript call to the button:
Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItem.ItemCreated
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
objDeleteButton.CssClass = "inputbutton"
objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
End If
End Sub
' client side code in javascript
function confirmDeleteItem()
{
if (confirm("Are you sure you wish to delete this item?"))
{
return true;
}
else
{
return false;
}
}
any help is appreciated. thank you.Sounds like you have validation controls on there, which causes the runtime
to emit yet another onClick handler which submits the form. Try using an
<input type="button"> instead of an <asp:button> control, and if you need
validation just script in the validation call (and, as always, make sure you
explicitly validate on the server, as client side validation is easy to
foil).
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in message
news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> I have a Delete button in my datagrid. I'm attempting to add some code
> confirming whether the user wishes to really delete the item or not.
> The confirm pops up, but I cannot suppress the submission when selecting
> Cancel.
> Heres what I have so far:
> ' adding the javascript call to the button:
> Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgItem.ItemCreated
> If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> ListItemType.AlternatingItem Then
> Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
> objDeleteButton.CssClass = "inputbutton"
> objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> End If
> End Sub
>
> ' client side code in javascript
> function confirmDeleteItem()
> {
> if (confirm("Are you sure you wish to delete this item?"))
> {
> return true;
> }
> else
> {
> return false;
> }
> }
> any help is appreciated. thank you.
Chris:
Thanks for the reply. I am struggling with this.
If I take your approach it seems I dont have the ability to wire it to the
DeleteCommand event. This means I have to access the DataKey for the row
through the client, which I dont want to do. I could be wrong on this
though.
All I really want to do is have a DeleteCommand button that performs a
delete with a confirmation prior to deletion. My code does not have any
other validators on the page. There is another button on the page, but
performs a completely unrelated task.
"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> Sounds like you have validation controls on there, which causes the
runtime
> to emit yet another onClick handler which submits the form. Try using an
> <input type="button"> instead of an <asp:button> control, and if you need
> validation just script in the validation call (and, as always, make sure
you
> explicitly validate on the server, as client side validation is easy to
> foil).
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
message
> news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > I have a Delete button in my datagrid. I'm attempting to add some code
> > confirming whether the user wishes to really delete the item or not.
> > The confirm pops up, but I cannot suppress the submission when selecting
> > Cancel.
> > Heres what I have so far:
> > ' adding the javascript call to the button:
> > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> dgItem.ItemCreated
> > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > ListItemType.AlternatingItem Then
> > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
Button)
> > objDeleteButton.CssClass = "inputbutton"
> > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > End If
> > End Sub
> > ' client side code in javascript
> > function confirmDeleteItem()
> > {
> > if (confirm("Are you sure you wish to delete this item?"))
> > {
> > return true;
> > }
> > else
> > {
> > return false;
> > }
> > }
> > any help is appreciated. thank you.
Aha - that's a special case I hadn't considered.
Try this article:
http://authors.aspalliance.com/aldo...xamples/cd.aspx
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Elliot M. Rodriguez" <someemail> wrote in message
news:ucDxzLAxDHA.2460@.TK2MSFTNGP10.phx.gbl...
> Chris:
> Thanks for the reply. I am struggling with this.
> If I take your approach it seems I dont have the ability to wire it to the
> DeleteCommand event. This means I have to access the DataKey for the row
> through the client, which I dont want to do. I could be wrong on this
> though.
> All I really want to do is have a DeleteCommand button that performs a
> delete with a confirmation prior to deletion. My code does not have any
> other validators on the page. There is another button on the page, but
> performs a completely unrelated task.
>
> "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
> news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> > Sounds like you have validation controls on there, which causes the
> runtime
> > to emit yet another onClick handler which submits the form. Try using an
> > <input type="button"> instead of an <asp:button> control, and if you
need
> > validation just script in the validation call (and, as always, make sure
> you
> > explicitly validate on the server, as client side validation is easy to
> > foil).
> > --
> > Chris Jackson
> > Software Engineer
> > Microsoft MVP - Windows Client
> > Windows XP Associate Expert
> > --
> > More people read the newsgroups than read my email.
> > Reply to the newsgroup for a faster response.
> > (Control-G using Outlook Express)
> > --
> > "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
> message
> > news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > > I have a Delete button in my datagrid. I'm attempting to add some code
> > > confirming whether the user wishes to really delete the item or not.
> > > > The confirm pops up, but I cannot suppress the submission when
selecting
> > > Cancel.
> > > > Heres what I have so far:
> > > > ' adding the javascript call to the button:
> > > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > dgItem.ItemCreated
> > > > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > > ListItemType.AlternatingItem Then
> > > > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
> Button)
> > > > objDeleteButton.CssClass = "inputbutton"
> > > > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > > > End If
> > > > End Sub
> > > > > > ' client side code in javascript
> > > > function confirmDeleteItem()
> > > > {
> > > > if (confirm("Are you sure you wish to delete this item?"))
> > > > {
> > > > return true;
> > > > }
> > > > else
> > > > {
> > > > return false;
> > > > }
> > > > }
> > > > any help is appreciated. thank you.
> >
Chris:
I realized I forgot the lousy "return" keyword in Attributes.Add lol...
Thanks for the article and the help.
"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:OwfPeBBxDHA.1196@.TK2MSFTNGP12.phx.gbl...
> Aha - that's a special case I hadn't considered.
> Try this article:
> http://authors.aspalliance.com/aldo...xamples/cd.aspx
>
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Elliot M. Rodriguez" <someemail> wrote in message
> news:ucDxzLAxDHA.2460@.TK2MSFTNGP10.phx.gbl...
> > Chris:
> > Thanks for the reply. I am struggling with this.
> > If I take your approach it seems I dont have the ability to wire it to
the
> > DeleteCommand event. This means I have to access the DataKey for the row
> > through the client, which I dont want to do. I could be wrong on this
> > though.
> > All I really want to do is have a DeleteCommand button that performs a
> > delete with a confirmation prior to deletion. My code does not have any
> > other validators on the page. There is another button on the page, but
> > performs a completely unrelated task.
> > "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
> > news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> > > Sounds like you have validation controls on there, which causes the
> > runtime
> > > to emit yet another onClick handler which submits the form. Try using
an
> > > <input type="button"> instead of an <asp:button> control, and if you
> need
> > > validation just script in the validation call (and, as always, make
sure
> > you
> > > explicitly validate on the server, as client side validation is easy
to
> > > foil).
> > > > --
> > > Chris Jackson
> > > Software Engineer
> > > Microsoft MVP - Windows Client
> > > Windows XP Associate Expert
> > > --
> > > More people read the newsgroups than read my email.
> > > Reply to the newsgroup for a faster response.
> > > (Control-G using Outlook Express)
> > > --
> > > > "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
> > message
> > > news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > > > I have a Delete button in my datagrid. I'm attempting to add some
code
> > > > confirming whether the user wishes to really delete the item or not.
> > > > > > The confirm pops up, but I cannot suppress the submission when
> selecting
> > > > Cancel.
> > > > > > Heres what I have so far:
> > > > > > ' adding the javascript call to the button:
> > > > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > > dgItem.ItemCreated
> > > > > > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > > > ListItemType.AlternatingItem Then
> > > > > > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
> > Button)
> > > > > > objDeleteButton.CssClass = "inputbutton"
> > > > > > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > > > > > End If
> > > > > > End Sub
> > > > > > > > > > ' client side code in javascript
> > > > > > function confirmDeleteItem()
> > > > > > {
> > > > > > if (confirm("Are you sure you wish to delete this item?"))
> > > > > > {
> > > > > > return true;
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > return false;
> > > > > > }
> > > > > > }
> > > > > > any help is appreciated. thank you.
> > > > > >
Suppressing the URL in a asp.net app
I've seen many Internet sites that suppress the URL or show the same URL all
the time your moving around different pages. You'll only see the real page
with it's path in the statusbar way down on the page.
How is that done in asp.net?
I have an example on this, in sweden, stockholm where I live we have a
wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
http://www.clasohlson.se/
You'll also have them on a flaglink in finnish, norwegian and english
language just above the statusbar. So that you see what I mean.
Any ideas?
TIA
Kenneth PThe above link (http://www.clasohlson.se/) is using a frameset. The
address bar isn't updated since you're navigating within a frame of the
page frameset.
Since HTML Framesets are a client side technology, this approach would
work the exact same in ASP.NET.
More info on frames here:
http://www.w3schools.com/html/html_frames.asp
- Jon
http://weblogs.asp.net/jgalloway
Hi
They are using frames. Just look at the main page "View -> Sourece" and you
will see that page have some frame.
With right click on page you'll see that page has url. Click on top and also
on bottom to see that the page url is different.
Also take a look on frame stuff to undestand clearly what is happening.
There is no trick made in asp.net in that page.
Cheers.
"Kenneth P" wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same URL all
> the time your moving around different pages. You'll only see the real page
> with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
Kenneth P wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same
> URL all the time your moving around different pages. You'll only see
> the real page with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas
> Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
That has nothing to do with asp.net or any other server-side technology,
it is client-side html.
The trick is to use a frameset as your first page. The URL shown is the url of that
frameset definition, the rest of the site works within that frameset.
For that site: use "View | Source" from the menu and scroll down to below the
<NOSCRIPT> section. (strange, a noscript section with embedded javascript...)
Hans Kesting
Hi jongalloway,
Hmmm...
Have you seen the same technology on pages without frames?
Kenneth P
"jongalloway" wrote:
> The above link (http://www.clasohlson.se/) is using a frameset. The
> address bar isn't updated since you're navigating within a frame of the
> page frameset.
> Since HTML Framesets are a client side technology, this approach would
> work the exact same in ASP.NET.
> More info on frames here:
> http://www.w3schools.com/html/html_frames.asp
> - Jon
> http://weblogs.asp.net/jgalloway
>
"Kenneth P" wrote:
> Hi jongalloway,
> Hmmm...
> Have you seen the same technology on pages without frames?
> Kenneth P
>
> "jongalloway" wrote:
> > The above link (http://www.clasohlson.se/) is using a frameset. The
> > address bar isn't updated since you're navigating within a frame of the
> > page frameset.
> > Since HTML Framesets are a client side technology, this approach would
> > work the exact same in ASP.NET.
> > More info on frames here:
> > http://www.w3schools.com/html/html_frames.asp
> > - Jon
> > http://weblogs.asp.net/jgalloway
Sorry about that empty post above, accidentally hit the Enter key :-)
here are some interesting articles that could solve your problem:
www.15seconds.com/issue/030522.htm
www.codeproject.com/aspnet/URLRewriter.asp
I hope this helps
"Tim Bens" wrote:
>
> "Kenneth P" wrote:
> > Hi jongalloway,
> > Hmmm...
> > Have you seen the same technology on pages without frames?
> > Kenneth P
> > "jongalloway" wrote:
> > > The above link (http://www.clasohlson.se/) is using a frameset. The
> > > address bar isn't updated since you're navigating within a frame of the
> > > page frameset.
> > > > Since HTML Framesets are a client side technology, this approach would
> > > work the exact same in ASP.NET.
> > > > More info on frames here:
> > > http://www.w3schools.com/html/html_frames.asp
> > > - Jon
> > > http://weblogs.asp.net/jgalloway
> >
Tim,
Thanks for the links.
Kenneth P
"Tim Bens" wrote:
> Sorry about that empty post above, accidentally hit the Enter key :-)
> here are some interesting articles that could solve your problem:
> www.15seconds.com/issue/030522.htm
> www.codeproject.com/aspnet/URLRewriter.asp
> I hope this helps
>
> "Tim Bens" wrote:
> > "Kenneth P" wrote:
> > > Hi jongalloway,
> > > > Hmmm...
> > > > Have you seen the same technology on pages without frames?
> > > > Kenneth P
> > > > > "jongalloway" wrote:
> > > > > The above link (http://www.clasohlson.se/) is using a frameset. The
> > > > address bar isn't updated since you're navigating within a frame of the
> > > > page frameset.
> > > > > > Since HTML Framesets are a client side technology, this approach would
> > > > work the exact same in ASP.NET.
> > > > > > More info on frames here:
> > > > http://www.w3schools.com/html/html_frames.asp
> > > > - Jon
> > > > http://weblogs.asp.net/jgalloway
> > > >
Suppressing the URL in a asp.net app
I've seen many Internet sites that suppress the URL or show the same URL all
the time your moving around different pages. You'll only see the real page
with it's path in the statusbar way down on the page.
How is that done in asp.net?
I have an example on this, in sweden, stockholm where I live we have a
wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
http://www.clasohlson.se/
You'll also have them on a flaglink in finnish, norwegian and english
language just above the statusbar. So that you see what I mean.
Any ideas?
TIA
Kenneth PThe above link (http://www.clasohlson.se/) is using a frameset. The
address bar isn't updated since you're navigating within a frame of the
page frameset.
Since HTML Framesets are a client side technology, this approach would
work the exact same in ASP.NET.
More info on frames here:
http://www.w3schools.com/html/html_frames.asp
- Jon
http://weblogs.asp.net/jgalloway
Hi
They are using frames. Just look at the main page "View -> Sourece" and you
will see that page have some frame.
With right click on page you'll see that page has url. Click on top and also
on bottom to see that the page url is different.
Also take a look on frame stuff to undestand clearly what is happening.
There is no trick made in asp.net in that page.
Cheers.
"Kenneth P" wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same URL a
ll
> the time your moving around different pages. You'll only see the real page
> with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
Kenneth P wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same
> URL all the time your moving around different pages. You'll only see
> the real page with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas
> Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
That has nothing to do with asp.net or any other server-side technology,
it is client-side html.
The trick is to use a frameset as your first page. The URL shown is the url
of that
frameset definition, the rest of the site works within that frameset.
For that site: use "View | Source" from the menu and scroll down to below th
e
<NOSCRIPT> section. (strange, a noscript section with embedded javascript...
)
Hans Kesting
Hi jongalloway,
Hmmm...
Have you seen the same technology on pages without frames?
Kenneth P
"jongalloway" wrote:
> The above link (http://www.clasohlson.se/) is using a frameset. The
> address bar isn't updated since you're navigating within a frame of the
> page frameset.
> Since HTML Framesets are a client side technology, this approach would
> work the exact same in ASP.NET.
> More info on frames here:
> http://www.w3schools.com/html/html_frames.asp
> - Jon
> http://weblogs.asp.net/jgalloway
>
"Kenneth P" wrote:
> Hi jongalloway,
> Hmmm...
> Have you seen the same technology on pages without frames?
> Kenneth P
>
> "jongalloway" wrote:
>
Sorry about that empty post above, accidentally hit the Enter key :-)
here are some interesting articles that could solve your problem:
www.15seconds.com/issue/030522.htm
www.codeproject.com/aspnet/URLRewriter.asp
I hope this helps
"Tim Bens" wrote:
>
> "Kenneth P" wrote:
>
Tim,
Thanks for the links.
Kenneth P
"Tim Bens" wrote:
> Sorry about that empty post above, accidentally hit the Enter key :-)
> here are some interesting articles that could solve your problem:
> www.15seconds.com/issue/030522.htm
> www.codeproject.com/aspnet/URLRewriter.asp
> I hope this helps
>
> "Tim Bens" wrote:
>