Modal BootStrap can not get variable asp from codebehind

0

Dear, good morning!

I'm starting and catching a lot on my first opportunity as a rsrs programmer

In My Sales2.aspx I have

<div id="myModal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- dialog body -->
      <div class="modal-body">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        Forma de Pagamento

        <%--  <%# Eval("desc_tp_pagamento") %>
          teste--%>
      </div>
        <div class="modal-body">

         Dados Pagto: <%=id_imobiliaria_pagamento%>
            <label id="lblteste"></label>


      </div>
      <!-- dialog buttons -->
      <div class="modal-footer"><button type="button" id="a.btn" class="btn btn-primary"data-dismiss="modal">OK</button></div>
    </div>
  </div>
</div>
            <%--#modalformapagto fim--%>

Here is the script that is being triggered via codebehind:

<script type="text/javascript">
                function myModal() {

                    $("#myModal").modal();

                    $("#myModal").on("show", function () {    // wire up the OK button to dismiss the modal when shown
                        $("#myModal a.btn").on("click", function (e) {
                            console.log("button pressed");   // just as an example...
                            $("#myModal").modal('hide');     // dismiss the dialog
                        });
                    })
                };
                    function myModalHide() {
                        $("#myModal").on("hide", function () {    // remove the event listeners when the dialog is dismissed
                            $("#myModal a.btn").off("click");
                        })
                    };

                    function myModalHidden() {
                        $("#myModal").on("hidden", function () {  // remove the actual elements from the DOM when fully hidden
                            $("#myModal").remove();
                        });

                        $("#myModal").modal({                    // wire up the actual modal functionality and show the dialog
                            "backdrop": "static",
                            "keyboard": true,
                            "show": true                     // ensure the modal is shown immediately
                        })
                    }
                ;
</script>

and here's the codbehind

public void gdvPagamentos_SelectIndexChanged(object sender, EventArgs e)
    {

        try
        {
            System.Threading.Thread.Sleep(1000);
            List<pagamento> pagto = new List<pagamento>();
            var id_imobiliaria_pagamento = gdvPagamentos.SelectedRow.Cells[0].Text;


            //ClientScript.RegisterClientScriptBlock(this.GetType(), "", "myModal();", true);
            ScriptManager.RegisterStartupScript
                 (Page,
                  this.GetType(),
                  "script",
                  "myModal();",
                  true);
        }
        catch(Exception ex){ }
    }

I declare the variable id_imobiliar_payment also outside the method and the data is recovered normal in codebehind.

But this same variable, with the modal open, and called in the html code inside the modal, shows nothing. Could someone help me?

    
asked by anonymous 13.10.2017 / 15:35

1 answer

0
In the codebehind, inside the method I had declared the variable of a form (example var xxxxx) and out of the method I had defined as string ... with this was occurring the problem of not displaying the same ... Strange that he accused no error. I fixed to string tb within the method and the contents of the variables came to be presented.

    
16.10.2017 / 18:46