在前端引导模式中使用c#中定义的按钮

Use the button defined behind in C# in front bootstrap modal

本文关键字:定义 按钮 模式 前端      更新时间:2023-09-26

我写这个是为了在我点击打开模式按钮后显示一个浮动窗口

 <button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">Open Modal</button>
    <div id="myModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Modal Header</h4>
                </div>
                <div class="modal-body" id="imghere">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
在这个例子中,我用 来定义按钮

 <button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">Open Modal</button>

现在我在c#中定义了一个按钮在

后面

protected void GenGridView()
    {
        var data = project.ObtainDataDescJSON();
        Title = "show";
        for (int rowCtr = 0; row < data.Num.Count; row++)
        {
            var buttonField = new ButtonField
            {
                ButtonType = ButtonType.Button,
                Text = "Show",
                CommandName = "Display"
            };
            ModelNumFieldsGrid.Columns.Add(buttonField);
            break;
        }
      }

我如何使用这些按钮我在c#中定义的引导模式?如何更改

 <button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">Open Modal</button>

应该使用像get element By ID这样的东西吗?我对Web开发真的很陌生,请帮忙!由于

你可以使用一个普通的按钮,而不是一个按钮字段,但这两种方式都应该做到这一点。或者你可以使用jQuery找到你添加的所有按钮,并以这种方式附加属性(首选)。

protected void GenGridView()
    {
        var data = project.ObtainDataDescJSON();
        Title = "show";
        for (int rowCtr = 0; row < data.Num.Count; row++)
        {
            var buttonField = new ButtonField
            {
                ButtonType = ButtonType.Button,
                Text = "Show",
                CommandName = "Display"
            };
            buttonField.Attributes.Add("data-toggle", "modal");
            buttonField.Attributes.Add("data-target", "#myModal");
            buttonField.CssClass = "btn btn-info";             
            ModelNumFieldsGrid.Columns.Add(buttonField);
            break;
        }
      }
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "modelBox", "$('#myModal').modal('show');", true);