4

I'm working on excel sheet where I'm writing data to the excel sheet after data being entered in the excel I'm downloading it to the local disk.

Then I want to show the popup that it has been downloaded successfully and written this code

ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
lblLog.Text = "Successfully Downloaded";

My JavaScript is

function openModal() {
    $('#myModal').modal('show');
}

My clickevent

<asp:LinkButton ID="linkbutton" runat="server" class="btn btn-primary btn-block" OnClick="linkbutton_Click" Text="Submit"  data-target="#myModal"></asp:LinkButton>

The excel is being downloaded but the popup is not showing

Ajay A
  • 127
  • 7

1 Answers1

0

There is a trick way to show model and trigger your Linkbutton Event

  1. Clear your LinkButton OnClick Event and Add OnClientClick="openModal()"

    <asp:LinkButton ID="linkbutton" runat="server" class="btn btn-primary btn-block" OnClientClick="openModal()" Text="Submit"  data-target="#myModal"></asp:LinkButton>
    
  2. Add trigget Linkbutton Event on your Javascript method

    function openModal() {
    
    $('#myModal').modal('show'); // If that is right method
    
    __doPostBack('linkbutton_Click', ''); //Trigger Linkbutton Event
    
    }
    

    ref:How to use dopostback

Community
  • 1
  • 1
King Jk
  • 1,069
  • 14
  • 22