JavaScript popup not working?

I am working on an excel sheet where I write data on an excel sheet after entering the data in excel. I download it to a local drive.

Then I want to show the popup that it was loaded successfully and wrote this code

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

My JavaScript-

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>

Excel loads, but popup does not show

+4
source share
1 answer

There are three ways to show the model and fire the Linkbutton event.

  • Clear the 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>
    
  • Add Linkbutton trigger event to your Javascript method

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

    ref: How to use dopostback

0
source

All Articles