Hi @Durgesh Pawar,
Have you tried that code and it still doesn't work?
Whether the drop-down list is inside or outside the modal box, it does not affect the use of the RegisterStartupScript method of the ClientScript class.
I tested your code and it works.
protected void CompanyNameDDL_SelectedIndexChanged(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Popup", "$('#NewVehicleCompany').modal('show')", true);
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList ID="CompanyNameDDL" runat="server" CssClass="form-control" AutoPostBack="true" OnSelectedIndexChanged="CompanyNameDDL_SelectedIndexChanged" data-toggle="dropdown" data-target="#NewVehicleCompany">
<asp:ListItem Text="Select Fruit" Value="0" />
<asp:ListItem Text="Mango" Value="1" />
<asp:ListItem Text="Apple" Value="2" />
<asp:ListItem Text="Banana" Value="3" />
</asp:DropDownList>
<%-- modal box--%>
<div id="NewVehicleCompany" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modal Box</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<!-- Add the content of the modal box here -->
This is the modal box content. </div>
<div class="modal-footer">
<asp:Button ID="btnCloseModal" runat="server" Text="Close" CssClass="btn btn-danger" data-dismiss="modal" />
</div>
</div>
</div>
</div>
</form>
</body>
</html>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.