asp.net | Open Bootstrap Modal in Repeater with click row v

This is for:
[1] Open a popup
[2] Pass a value

In <asp:Repeater> add the button with CommandName and CommandArgument

 <asp:Button runat="server" ID="Button1" text="btn" CommandName="MyCommand" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "MyIDValue") %>' ></asp:Button>

Code behind

Private Sub RepeaterName_ItemCommand(source As Object, e As RepeaterCommandEventArgs) Handles RepeaterName.ItemCommand

        If (e.CommandName = "MyCommand") Then
            'getID
            Dim MyId As Integer = Integer.Parse(e.CommandArgument.ToString)

text_value.text = MyID

// This script to register the modal javascript
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Pop", "openModal();", True)

        End If
    End Sub

HTML code

    <script type="text/javascript">function openModal() { $('#model_del_gov_lic').modal('show'); }</script>

    <div id="model_del_gov_lic" class="modal fade" role="dialog">
        <div class="modal-dialog">

            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button><h4 class="modal-title">Header text</h4>
                </div>
                <div class="modal-body ar">

                <asp:Label runat="server" ID="text_value" />
                  
                </div>
                </div>
                <div class="modal-footer">
                   [Buttons]
                </div>
            </div>
        </div>
    </div>

,

Leave a Reply

Your email address will not be published. Required fields are marked *