How to show pop-up window asp c #

0

Good afternoon.

I would like you to help me, I'm doing a modal that runs as long as it registers and an error message appears.

So far what I have achieved if you register but the modal message is not displayed.

I'm doing my insertion with sql server and asp c # the error message is one of my output variables from my procedure.

the code "+ message +": it is an output variable that in my procedure tells me if the registration is correct or the registration or duplicate data was not processed. the record already exists

This is the code of my code-behind:

cmd.Parameters["@idregistrotarea"].Value = lblidregistrotareas.Text;
cmd.Parameters["@usuario"].Value = lblatendidopor.Text;
cmd.Parameters["@fechaemision"].Value = lblfechareg.Text;
cmd.Parameters["@fechacumplimiento"].Value = TxtFechaPago.Text;
cmd.Parameters["@fechaatendido"].Value = TxtFecha.Text;
cmd.Parameters["@montopagado"].Value = TxtMontoPagado.Text;
cmd.Parameters["@numerorecibo"].Value = txtNumeroRecibo.Text;
cmd.Parameters["@tarea"].Value = dprTarea.Text;
cmd.Parameters["@oficina"].Value = dprAgencia.SelectedValue;
cmd.Parameters["@fechaemisions"].Value = txtFechaEmision.Text;
cmd.Parameters["@comentario"].Value = txtComentario.Text;
cmd.Parameters["@fechacumplimientotarea"].Value = txtfechaoculta.Text;
cmd.Parameters["@ERROR"].Direction = ParameterDirection.Output;
cn.Open();
BtnnoConforme.Enabled = false;
cmd.ExecuteNonQuery();
message = (string)cmd.Parameters["@ERROR"].Value;

ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", message, true);
cn.Close();

TxtMontoPagado.Text = "";
txtNumeroRecibo.Text = "";
TxtFecha.Text = "";
                }
}

This is the code of my HTML.

<script type="text/javascript">
   function showmodalpopup1() {
       $("#popupdiv").dialog({

           width: 400,
           height: 150,
           autoOpen: true,
           draggable: false,
           resizable: false,
           hide: "slide",
           modal: true,


       });
   };

</script>
div id="popupdiv" title="Basic modal dialog" style="display: none;">

    
asked by PieroDev 24.03.2017 в 21:38
source

1 answer

1

The first thing is that the Close of the connection to BBDD should be done immediately after the query, before the ScriptManager.

message = (string)cmd.Parameters["@ERROR"].Value;
cn.Close();

The ScriptManager is missing things, the text can not pass only.

ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", 'var ElMensaje = "' + message + '";', true);

With this, you will have managed to pass the text to your javascript in the variable ElMensaje. Insert the content of the variable in your DIV and finally open the Dialog of jQuery.

<script type="text/javascript">
   function showmodalpopup1() {
       $("#popupdiv").text(ElMensaje);

       $("#popupdiv").dialog({

           width: 400,
           height: 150,
           autoOpen: true,
           draggable: false,
           resizable: false,
           hide: "slide",
           modal: true,


       });
   };

</script>
    
answered by 29.03.2017 в 12:50