Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/11/2014, 16:05
davidosky
 
Fecha de Ingreso: noviembre-2014
Mensajes: 6
Antigüedad: 9 años, 5 meses
Puntos: 0
Respuesta: llamar método mediante javascript

gracias por responder @Drako_18, lastimosamente aun no pude resolverlo, audjunto el codigo q me indicas
pagina aspx
Código:
<script type="text/jscript">
        function confirmarEliMate() {
            var seleccion = confirm("No se pudo eliminar la materia, esto se debe a que la materia se está dictando actualmente o ya se dictó. De todas formas, ¿Desea deshabilitar esta materia?");
            if (seleccion) {
                var objBoton = document.getElementById("ButtonMatDes");
                if (objBoton) {
                    objBoton.click();
                }
            }
        }
    </script>
    <asp:UpdatePanel ID="UpdatePanelMateria" runat="server">
    <ContentTemplate>
<asp:Panel ID="CabeceraPanelMateria" runat="server" style="cursor: pointer;">
        <div class="Cabecera">
            <asp:ImageButton ID="ImagenFlecha1" runat="server" ImageUrl="~/Imagen/collapse.jpg" AlternateText="collapse" />
            Administrar las materias
        </div>
    </asp:Panel>
    <asp:Panel id="ContenidoPanelMateria" runat="server" style="overflow:hidden;">
<asp:Button ID="ButtonMatEli" runat="server" Text="Eliminar" onclick="ButtonMatEli_Click" />
        <asp:Button ID="ButtonMatDes" runat="server" Text="Deshabilitar" onclick="ButtonMatDes_Click" /></asp:Panel>
</ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ButtonMatEli" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="ButtonMatDes" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
y el codigo c# es:

Código:
protected void Page_Load(object sender, EventArgs e)
    {
        ButtonMatEli.Attributes.Add("onclick", "return confirm('Presione Aceptar si esta seguro de eliminar la materia');"); 
    }
protected void ButtonMatEli_Click(object sender, EventArgs e)
    {
        ControladorMateria ControMater = new ControladorMateria();
        if (ControMater.Eliminar(TextBoxMatID.Text))
        {
            string script = @"<script type='text/javascript'> 
                alert('Se ha eliminado la materia seleccionada.');
                </script>";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
        }
        else
        {
            string script = @"<script type='text/javascript'>
                                confirmarEliMate();
                            </script>";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "confirmarEliMate", script, false);
        }
        Lista_MateriasH();
    }
protected void ButtonMatDes_Click(object sender, EventArgs e)
    {
    }