Jan 10, 2021 10:02 PM|anjaliagarwal5@yahoo.com|LINK
I need to show a delete conformation box on Gridview delete. with OnClientClick confirmation box, I am showing a simple Internet explore box for delete confirmation. Is it possible to show a fancy box for this. below is my JavaScript code that exists inside
the gridview code:
Can I use JQuery Mobile Dialog, but not sure how can I sue it with onCLientClick
You can use whatever client side library you like. The key is understanding the confirm dialog stops JavaScript code execution while waiting for the user's selection. A JavaScript library, like the jQuery dialog, is asynchronous and requires coding and
design. Typically a standard HTML button is used so the form does not post. If you use a link button then you also have to cancel the link button's default submit using JavaScript.
Anyway, the jQuery modal's button should submit the form. Since this Web Forms programming problem has been solved many many many times with tons and tons and tons of online examples and you have a lot of experience on the forums, I think you should try
to write the code on your own.
If you run into trouble, then share code that any forum member can run to reproduce the issue. Explain the expected results and the actual results. Pretty standard stuff...
Jan 11, 2021 12:58 AM|anjaliagarwal5@yahoo.com|LINK
you mentioned, I can use modalpop. I am not sure how I can do that. I am posting my question again. May be, someone else can help me with this:
I am trying to show a modalpop inside the gridview when the delete button is clicked. The gridview control is inside the .ascx page and
I can show the modal pop up in the panel or outside the side panel or may be the modal pop up is showing but it is coming to the right side of the panel and I cannot see it. This is a very simple example that I created:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SidePanelGridViewTest
{
public partial class GridViewUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
string x = "Test";
}
}
}
I didn't put any code inside OnRowDeleting because I just want to see the postback and the postback is not occurring because of modalpopup.below is my .aspx page:
I meant that because you could not achieve it (i.e., show a dialog for confirmation) by using the ModalPopup use of the jQuery Mobile Dialog instead will result in the same.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Jan 11, 2021 05:11 PM|anjaliagarwal5@yahoo.com|LINK
Hi Xudong Peng,
I can see the pop up box, but the issue is when I click on any button on the modal pop up, the side panel closes and the postback does not occur. Instead of modal pop, simple javascript conformation works and causes postback too:
<script type="text/javascript">
function DeleteItem() {
if (confirm("Delete this Location?")) {
return true;
} else {
return false;
}
}
</script>
The only issue with this is, the pop up window looks kind of ugly. I want the look similar to the modal pop up window. Below is how the modal pop up window looks like. Can you suggest something so that the look of Javascript window is similar to modalpopup
window.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Jan 12, 2021 10:16 AM|anjaliagarwal5@yahoo.com|LINK
Thanks. Above code works fine, but when I put the bootstrap modal inside the gridview then it didnt work. I tried to do it another way by calling Jquery UI dialog from the gridview delete click. That doesn't seem to be working either, but I am posting my
code in case someone can suggest something otherwise I will just stick with simple JavaScript.
Below is my entire code including my jquery function:
If you can give up the jQuery Mobile and can use the Bootstrap Modal instead and also for the confirmation dialog you will probably be able to show both the shopping cart and confirmation dialog in order as required.
But, keep in mind there will be another big issue as to how you can delete the selected records in the database.
Jan 13, 2021 06:09 PM|anjaliagarwal5@yahoo.com|LINK
I will just keep the simple Javascript comfirmation box with Jquery Mobile panel. I just wanted to beautify the javascript confirmation box. I think it is not possible.
Member
505 Points
1259 Posts
gridview row delete confirmation box
Jan 10, 2021 10:02 PM|anjaliagarwal5@yahoo.com|LINK
I need to show a delete conformation box on Gridview delete. with OnClientClick confirmation box, I am showing a simple Internet explore box for delete confirmation. Is it possible to show a fancy box for this. below is my JavaScript code that exists inside the gridview code:
OnClientClick="return DeleteItem();"
Below is my Gridview
<asp:GridView ID="grdShoppingCart" runat="server" AutoGenerateColumns="false" class="ui-responsive table-stroke ss-table ui-search-result-table" DataKeyNames="CartID" AllowPaging="false" PageSize="5" GridLines="None" OnRowDataBound="grdShoppingCart_RowDataBound" OnRowDeleting="grdShoppingCart_RowDeleting"> <Columns> <asp:BoundField DataField="CartID" Visible="false" HeaderText="CartID" /> <asp:BoundField DataField="item" HeaderText="Item" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="250px" ControlStyle-CssClass="ss-row" /> <ItemTemplate> <asp:ImageButton ID="imgbtnDelete" runat="server" ImageUrl="~/Images/delete1.png" title='Remove' CommandName="delete" OnClientClick="return DeleteItem();" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
This is my Javascript function:
<script type="text/javascript"> function DeleteItem() { if (confirm("Delete this Location?")) { return true; } else { return false; } } </script>
above code is showing this confirmation window:
I want to show something like this:
any help will be apprecaited.
Member
150 Points
103 Posts
Re: gridview row delete confirmation box
Jan 10, 2021 10:55 PM|SurferOnWww|LINK
Does your project include the Bootstrap.css and Bootstrap.js? If so, consider to use the Modal of Bootstrap.js.
Member
505 Points
1259 Posts
Re: gridview row delete confirmation box
Jan 10, 2021 11:23 PM|anjaliagarwal5@yahoo.com|LINK
Can I use JQuery Mobile Dialog, but not sure how can I sue it with onCLientClick
Member
150 Points
103 Posts
Re: gridview row delete confirmation box
Jan 10, 2021 11:41 PM|SurferOnWww|LINK
Please do not reply by asking question but answer to my question first.
Member
505 Points
1259 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 12:06 AM|anjaliagarwal5@yahoo.com|LINK
No, my project does not include bootstrap.js.
All-Star
52091 Points
23207 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 12:11 AM|mgebhard|LINK
You can use whatever client side library you like. The key is understanding the confirm dialog stops JavaScript code execution while waiting for the user's selection. A JavaScript library, like the jQuery dialog, is asynchronous and requires coding and design. Typically a standard HTML button is used so the form does not post. If you use a link button then you also have to cancel the link button's default submit using JavaScript.
Anyway, the jQuery modal's button should submit the form. Since this Web Forms programming problem has been solved many many many times with tons and tons and tons of online examples and you have a lot of experience on the forums, I think you should try to write the code on your own.
If you run into trouble, then share code that any forum member can run to reproduce the issue. Explain the expected results and the actual results. Pretty standard stuff...
Member
150 Points
103 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 12:56 AM|SurferOnWww|LINK
> Can I use JQuery Mobile Dialog, but not sure how can I sue it with onCLientClick
No, I do not think you can.
If you can you could use the ModalPopup for that purpose properly in the previous thread. Therefore, I suggest you stay in using the confirm method.
Member
505 Points
1259 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 12:58 AM|anjaliagarwal5@yahoo.com|LINK
you mentioned, I can use modalpop. I am not sure how I can do that. I am posting my question again. May be, someone else can help me with this:
I am trying to show a modalpop inside the gridview when the delete button is clicked. The gridview control is inside the .ascx page and I can show the modal pop up in the panel or outside the side panel or may be the modal pop up is showing but it is coming to the right side of the panel and I cannot see it. This is a very simple example that I created:
Below is the .ascx page code:
below is the code behind of .ascx page:
I didn't put any code inside OnRowDeleting because I just want to see the postback and the postback is not occurring because of modalpopup.below is my .aspx page:
There is no code behind the .aspx page.</div>
Member
150 Points
103 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 05:18 AM|SurferOnWww|LINK
> you mentioned, I can use modalpop.
It is misunderstanding.
I meant that because you could not achieve it (i.e., show a dialog for confirmation) by using the ModalPopup use of the jQuery Mobile Dialog instead will result in the same.
Sorry if my previous replay caused any confusion.
Participant
1780 Points
553 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 07:08 AM|XuDong Peng|LINK
Hi anjaliagarwal5,
According to the code you provided, I tried to reproduce your issue and get the same result.
If you want to display this modal popup where you can see it, have you tried to set position style?
A simple test:
<asp:Panel ID="pnlPopUp" runat="server" Style="display: none; background-color: white;left:-260%;" > <asp:Panel ID="pnlDragPopUp" runat="server" Style="cursor: move; background-color: #dddddd; border: solid 1px Gray; color: Black; width: 500px"> <div role="main" class="ui-content"> <h3 class="ui-title">Are you sure you want to remove this item?</h3> </div> </asp:Panel> <div> <p style="display: flex; align-items: center; justify-content: space-between; width: 220px;"> <asp:Button ID="OkButton" runat="server" Text="Remove" CommandName="delete" CommandArgument='<%#Eval("id") %>' /> <asp:Button ID="CancelButton" runat="server" Text="Cancel" /> </p> </div> </asp:Panel>
Result:
Hope this can help.
Best regards.
Xudong Peng
Member
505 Points
1259 Posts
Re: gridview row delete confirmation box
Jan 11, 2021 05:11 PM|anjaliagarwal5@yahoo.com|LINK
Hi Xudong Peng,
I can see the pop up box, but the issue is when I click on any button on the modal pop up, the side panel closes and the postback does not occur. Instead of modal pop, simple javascript conformation works and causes postback too:
This is my Javascript function:
The only issue with this is, the pop up window looks kind of ugly. I want the look similar to the modal pop up window. Below is how the modal pop up window looks like. Can you suggest something so that the look of Javascript window is similar to modalpopup window.
Participant
1780 Points
553 Posts
Re: gridview row delete confirmation box
Jan 12, 2021 09:53 AM|XuDong Peng|LINK
Hi anjaliagarwal5,
For the first question, jquery mobile overlay panel will automatically close when the mouse click position is not in the panel by default.
You need to set it to be closed manually.
Something like this:
In addition, according to the style of the pop-up box you described, I think you can try the Bootstrap Modal mentioned by other members.
Just make some modifications to it, a simple demo:
Result:
Hope this can help you.
Best regards,
Xudong Peng
Member
505 Points
1259 Posts
Re: gridview row delete confirmation box
Jan 12, 2021 10:16 AM|anjaliagarwal5@yahoo.com|LINK
Thanks. Above code works fine, but when I put the bootstrap modal inside the gridview then it didnt work. I tried to do it another way by calling Jquery UI dialog from the gridview delete click. That doesn't seem to be working either, but I am posting my code in case someone can suggest something otherwise I will just stick with simple JavaScript.
Below is my entire code including my jquery function:
Member
150 Points
103 Posts
Re: gridview row delete confirmation box
Jan 13, 2021 08:43 AM|SurferOnWww|LINK
If you can give up the jQuery Mobile and can use the Bootstrap Modal instead and also for the confirmation dialog you will probably be able to show both the shopping cart and confirmation dialog in order as required.
But, keep in mind there will be another big issue as to how you can delete the selected records in the database.
Member
505 Points
1259 Posts
Re: gridview row delete confirmation box
Jan 13, 2021 06:09 PM|anjaliagarwal5@yahoo.com|LINK
I will just keep the simple Javascript comfirmation box with Jquery Mobile panel. I just wanted to beautify the javascript confirmation box. I think it is not possible.
Member
150 Points
103 Posts
Re: gridview row delete confirmation box
Jan 13, 2021 11:53 PM|SurferOnWww|LINK
Can you close this thread (and the other threads related to this issue if any).