I have a user control that has a GridView
and when a user clicks on a row in this GridView
the function OnSelectedIndexChanged
is called, I'd like a modal to pop up after this occurs. I used the ScriptManager
to invoke the script $('#seasonInfoModal').modal()
which works in opening modals. The problem is it doesn't work when opening a modal which is defined within the same user control. The modal opens when it is inside the page.aspx
, but doesn't open when inside the control .ascx
. I have everything hooked up properly and have omitted some details. Here's what the overall code looks like
main page.aspx
<%@ Page Title="" Language="C#" ... %>
<%@ Register Src="~/Controls/MyControl.ascx" TagPrefix="ACT" TagName="GeneralADM" %>
<ACT:GeneralADM runat="server"" />
MyControl.ascx
<%@ Language="C#" AutoWireUP="true" Codebehind="" Inherits="" %>
<div runat="server">
<!-- Seasonal Info-->
<div runat="server" id="seasonInfoModal" class="modal fade" role="dialog" draggable="true">
</div>
<!-- End seasonal info-->
<!-- Start of Season Edit Modal -->
<div id="seasonEditInfo" class="modal fade" role="dialog" draggable="false">
</div>
<!-- End of Season Edit Modal -->
<asp:GridView>
</asp:GridView>
</div>
In the code behind I try to open the modal like this
MyControl.ascx.cs
protected void OnSelectedIndexChanged(object sender, GridViewEventArgs e){
ScriptManager.RegisterStartupScript(this,
this.GetType(),
"seasonInfoModal",
"$('#seasonInfoModal').modal();",
true);
}
issue
#seasonInfoModal
doesn't popup instead a new modal is made with nothing inside it and the screen fades to dark on click. When I pull the #seasonInfoModal
out of the control into the page where I am inserting the control itself, the modal actually pops up.
question
How can I open the modal #seasonInfoModal
when it is inside the control from that control's codebehind specifically from inside OnSelectedIndexChanged
function?