Modal Bootstrap cannot pick up variable

Asked

Viewed 92 times

0

Dear friends, good morning!

I am starting and catching up on my first opportunity as a rsrs programmer

In Minhasvendas2.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 the script being fired 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 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){ }
    }

declared the variable id_immobiliaria_payment also out of the method and the data is recovered normal in codebehind.

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

  • welcome to stackoverflow, is that your answer part of your question? , click Editar your question (bottom left corner)and put the code in it.

  • it was wrong rsrs

  • Thanks! So, I’m getting beaten for not being able to do the modal when open pull the value of this variable there... in the waiting for suggestions... vlw!!!

1 answer

0

In the codebehind, within the method I had declared the variable in one way (example var xxxxx) and outside the method I had defined as string... with this occurring the problem of not displaying it... Strange that it did not show error. Fixed for tb string within the method and the contents of the variables are now presented.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.