my model popup not opening with control button
Opening with input type = button
my code is given below
HTML
Code
VB.NET Modal Popup Example
Open Modal
Modal Heading
This is the modal content.
Close
--%>-----------------------------------------------------------------------------------------------------------------------------------
click event is
VB.NET
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ClientScript.RegisterStartupScript(Me.GetType(), "showModal", "$('#myModal').modal('show');", True)
End SubPlease Suggest How to do it ???

Naimish MakwanaRank #324 · 7.7K reputationPosted Jan 18, 2024, 6:38 AM EST
You can try to prevent the postback by returning false in the OnClientClick event of the ASP.NET button. Here’s how you can modify your button:
And add this script to your page:
function showModal() { $('#myModal').modal('show'); }This way, when you click the button, it will call the
showModalJavaScript function and prevent the postback, keeping your modal open. Please give it a try and let me know if it works for you.Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Jan 19, 2024, 12:57 AM EST
Hello Rupesh,
Please try this one it will work for you,
Sachin SinghRank #66 · 26.2K reputationPosted Jan 18, 2024, 10:35 AM EST
1.Remove the
data-bs-toggleanddata-bs-targetattributes from theasp:Button2.In your code-behind, handle the button click event and register the JavaScript code to open the modal.
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ClientScript.RegisterStartupScript(Me.GetType(), "showModal", "$('#myModal').modal('show');", True) End Sub