Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Approach Followed:
Actually,for deleting some data present in List View.I am going through ajax call
and finding some data from DataBase with respect to that id.And showing that data on Popup.
Now if user OK then it should perform the action through item command otherwise not.

Problem:
Confirm Popup is automatically hiding itself.And automatically it goes on Row Command.

function RemindersCount(Type, ActivityId) {
      $.ajax({
          url: "AddProduct.aspx/RemindersActive",
          type: "POST",
          contentType: "application/json;charset=utf-8",
          dataType: "json",
          data: "{ Type:'" + Type + "',  ActivityId:'" + ActivityId + "' }",
          cache: false,
          success: function (data) {
              var obj = JSON.parse(data.d);
              var action = confirm('If you delete the Activity.Your ' + obj.ActiveCount + ' active Reminders will also be deleted.');

              if (action) {


                  return true;
              }
              else {

                  return false;
              }
          },
          error: function (ex) {
              return false;
          }
      });
  }

The above ajax function is called By LinkButton present in List View.
<asp:LinkButton ID="lnkRemoveOpenActivity" OnClientClick='<%# string.Format("return RemindersCount(\"{0}\",\"{1}\");", Eval("Source"),Eval("RecordId")) %>'
    CommandName="RemoveFollowUp" CommandArgument='<%# Eval("RecordId")%>' runat="server"
    ToolTip="Remove" CssClass="temp">class="icon-remove"></asp:LinkButton>
Posted
Updated 29-Jan-16 18:37pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Jan-16 12:35pm    
What kind of "Popup"? Any code sample or a link? JavaScript "confirm" (would be a bad idea)? Modal popup? Or just creating a new browser window (just "popup", also a bad idea)? Why it's "hiding"? Based on your information, we cannot figure it out, only you can.

What does it mean "automatically goes on Row Command"? Popup? "Goes"? :-)

—SA
_RishabhGupta 29-Jan-16 12:52pm    
i mean that the confirm box should be come first.If user select the OK then it
should goto itemcommand(ListView) otherwise on cancel i am returning false.
Richard Deeming 29-Jan-16 13:39pm    
Click "Improve question" and post the relevant parts of your code. Include the ASPX markup of the button, and any javascript functions that it calls.

Remember to wrap your code blocks in <pre>...</pre> tags, and ensure that the code is properly HTML-encoded - &lt; instead of <, &gt; instead of >, etc.
_RishabhGupta 30-Jan-16 0:39am    
Hi Richard please go through the code and tell me what is going wrong.
Richard Deeming 1-Feb-16 7:55am    
Your RemindersCount function does not return a value. It starts an asynchronous AJAX request to the server, and then exits without returning a value. Since you haven't cancelled the event, the LinkButton then causes a postback to the server, and executes the command.

https://api.jquery.com/jQuery.ajax/[^]

1 solution

I would advise the following. Don't use confirm. Not only such dialogs are not flexible; they are ugly, inconvenient and hardly can be suitable for production-grade sites. Much better idea is using so called modal popup approach. Please see my article where I explain how they work, how you can create your own one, and discuss the alternatives, including confirm and other native JavaScript dialogs:
Modal Popup From Scratch[^].

Most popular implementation of modal popup is jQuery Dialog and many 3rd-party jQuery plug-ins:
Dialog | jQuery UI[^],
Let me google that for you[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900