保持对话框上的验证失败开放

努力实现这个没有Ajax ..

JavaScript的

jQuery(function () { // Modal Login. jQuery(".ModalBoxLogin").dialog({ autoOpen: false, bgiframe: true, height: 155, resizable: false, draggable: false, width: 353, modal: true, open: function (type, data) { // Hide Close jQuery(".ui-dialog-titlebar-close").hide(); // include modal into form jQuery(this).parent().appendTo(jQuery("form:first")); //clear all text. jQuery(this).find(':text').val(''); jQuery(this).find(':password').val(''); }, close: function () { //clear all text. jQuery(this).find(':text').val(''); jQuery(this).find(':password').val(''); } }); });

HTML

<%--Login Dialog--%> <asp:Panel ID="pnlLogin" runat="server" CssClass="ModalBoxLogin" title="LOGIN"> <div class="ModalBox_conteudo"> <div class="ModalBox_esq"> <asp:Label ID="lblEmail" Text="E-MAIL:" runat="server" /> <asp:Label ID="lblSenha" Text="SENHA:" runat="server" /> </div> <div class="ModalBox_dir"> <asp:TextBox ID="txtEmail" runat="server" placeholder="Digite o seu e-mail" /> <br /> <asp:TextBox ID="txtSenha" TextMode="Password" runat="server" placeholder="Digite a sua senha"/> <br /> <asp:LinkButton ID="btnLogar" runat="server" CssClass="btnOk" OnClick="btnLogar_Click" /> <br/> <asp:Label ID="lblMensagemLogin" runat="server"></asp:Label> <asp:Literal ID="litScriptLogin" runat="server"></asp:Literal> </div> <div class="ModalBox_links"> <asp:HyperLink ID="hlCadastroLogin1" NavigateUrl="" Text="Ainda não tem cadastro?" runat="server" /> <span>&nbsp;|&nbsp;</span> <asp:HyperLink ID="hlCadastroLogin2" NavigateUrl="" Text="Esqueceu a senha?" runat="server" /> </div> </div> </asp:Panel>

CS

protected void btnLogar_Click(object sender, EventArgs e) { ControllerCliente controllerCliente = new ControllerCliente(); controllerCliente.Cliente.Email = txtEmail.Text; controllerCliente.Cliente.Senha = Util.Criptografar(txtSenha.Text); controllerCliente.Carregar(); if (controllerCliente.Cliente.ClienteCodigo > 0) { hlLogin.Visible = false; hlCadastro.Visible = false; lblP.Text = "Olá " + controllerCliente.Cliente.Nome; ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "dialog", "alert('oi');", true); //litScriptLogin.Text = "<script>alert('teste');</script>"; //litScriptLogin.Text = "<script>getElementById('" + pnlLogin.ClientID + "').style.display='none';</script>"; //pnlLogin.Style["display"] = "none"; } else lblMensagemLogin.Text = "Email ou senha inválido."; }

如果我使用的UpdatePanel在本节:

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:LinkButton ID="btnLogar" runat="server" CssClass="btnOk" OnClick="btnLogar_Click" /> <br/> <asp:Label ID="lblMensagemLogin" runat="server"></asp:Label> <asp:Literal ID="litScriptLogin" runat="server"></asp:Literal> </ContentTemplate> </asp:UpdatePanel>

当我成功的对话框不会关闭。

任何,我很想念呀?

商祺

编辑:只是增加了一些东西...

javascript调用:

/* Modal */ jQuery(".ModalBoxOpenLogin").live("click", function myfunction() { jQuery(".ModalBoxLogin").dialog("open"); }); jQuery(".ModalBoxOpenCadastro").live("click", function myfunction() { jQuery(".ModalBoxCadastro").dialog("open"); });

HTML召唤:

<asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:HyperLink ID="hlLogin" runat="server" Text="Log in" CssClass="menu_log_menu ModalBoxOpenLogin"></asp:HyperLink> <asp:Label ID="lblP" runat="server" Text="|" style="margin-left:5px; cursor:default;color:#CCCCCC;" ></asp:Label> <asp:HyperLink ID="hlCadastro" runat="server" Text="Cadastre-se" CssClass="menu_log_menu ModalBoxOpenCadastro"></asp:HyperLink> </ContentTemplate> </asp:UpdatePanel>

分类:C# 时间:2015-03-15 人气:0
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.463 (s). 10 q(s)