ASP.NET Web Forms and AjaxControlToolkit

2

Adding a ajax:ModalPopupExtender to my page I'm having the following error

<%@PageTitle="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Devcompy.ClientWebForms.Admin.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content runat="server" ContentPlaceHolderID="ScriptContent">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:Panel ID="Panel1" runat="server">Teste</asp:Panel>
    <ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
        TargetControlID="Button1"
        PopupControlID="Panel1"
        BackgroundCssClass="modalBackground">
    </ajax:ModalPopupExtender>
</asp:Content>

Admin.master

<%@ Master Language="C#" MasterPageFile="~/Admin/AdminBase.Master" AutoEventWireup="true" CodeBehind="~/Admin/Admin.master.cs" Inherits="Devcompy.ClientWebForms.Admin.AdminMasterPage" %>

<%@ Register Src="MensagemUserControl.ascx" TagName="MensagemUserControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title>Devcompy40</title>
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="Content5" runat="server" ContentPlaceHolderID="ScriptContent">
    <asp:ContentPlaceHolder ID="ScriptContent" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderBodyContent" runat="server">
    <div class="title">
        <h1>Devcompy 40
        </h1>
    </div>
    <div class="loginDisplay">
        <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
            <AnonymousTemplate>
                [ <a href="~/Admin/Login/LoginPage.aspx" id="HeadLoginStatus" runat="server">Entrar</a> ]
            </AnonymousTemplate>
            <LoggedInTemplate>
                Bem Vindo <span class="bold">
                    <asp:LoginName ID="HeadLoginName" runat="server" />
                </span>! [
                <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Sair" LogoutPageUrl="~/Admin/Default.aspx" />
                ]
            </LoggedInTemplate>
        </asp:LoginView>
    </div>
    <div class="clear hideSkiplink">
        <asp:LoginView ID="LoginView1" runat="server" EnableViewState="false">
            <AnonymousTemplate>
            </AnonymousTemplate>
            <LoggedInTemplate>
                <asp:UpdatePanel ID="MainMenuUpdatePanel" runat="server">
                    <ContentTemplate>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </LoggedInTemplate>
        </asp:LoginView>
        <noscript>
            <div class="disabled" style="background-color: White; padding: 10px;">
                <img src='<%= ResolveUrl("~/Imagens/no.gif") %>' width="16" height="16" alt="javascript disabled" />
                O JavaScript está desabilitado no seu navegador. Quando habilitar seu JavaScript recarregue esta página que este aviso desaparecerá.
            </div>
        </noscript>
        <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" IncludeStyleBlock="False" ClientIDMode="Static" EnableViewState="true" Orientation="Horizontal"
            MaximumDynamicDisplayLevels="30">
            <DataBindings>
                <asp:MenuItemBinding DataMember="siteMapNode" NavigateUrlField="url" SelectableField="Selectable" TextField="title" />
            </DataBindings>
        </asp:Menu>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <asp:SiteMapPath ID="SiteMapPath1" runat="server" SiteMapProvider="WebAdminSiteMap" EnableViewState="false" CurrentNodeStyle-ForeColor="Black" RenderCurrentNodeAsLink="True">
            <CurrentNodeStyle ForeColor="Blue" Font-Bold="True"></CurrentNodeStyle>
        </asp:SiteMapPath>
    </div>
    <div style="margin-bottom: 40px;">
        <div>
            <uc1:MensagemUserControl ID="MensagemUserControl1" runat="server" />
        </div>
        <div class="clear main">
            <div class="clear">
                <div id="loading">
                    <asp:ContentPlaceHolder ID="MainContent" runat="server" />
                </div>
                <div style="float: right;">
                    <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="window.print();" EnableViewState="false">Imprimir Página</asp:LinkButton>
                </div>
            </div>
            <div class="clear">
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" runat="server" ContentPlaceHolderID="FooterContent" EnableViewState="false">
    <span>
        <%= DateTime.Now.Year %>
        - Copyright todos direitos reservados para <a href="http://www.deltacompy.com.br">Grupo Deltacompy</a> - Informática - Santa Maria/RS</span>
</asp:Content>

Admin.Master.cs

using System;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Devcompy.Repositories.Web.Base;
using System.IO;
using Devcompy.Repositories.Business2.Seguranca;

namespace Devcompy.ClientWebForms.Admin
{
    public partial class AdminMasterPage : DevcompyMasterPage
    {
        protected override void PageLoad()
        {            
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "RegistrarJquery", "RegistrarJquery();", true);
            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "ConfirmDialog", " ConfirmDialog(this, ''); ", true);

            if (!Request.RawUrl.Contains("/Admin/Login/LoginPage.aspx"))
            {
                if (this.UsuarioId == 0)
                {
                    FormsAuthentication.SignOut();
                    FormsAuthentication.RedirectToLoginPage();
                }
            }

            if (!this.IsPostBack)
            {
                if ((!Request.RawUrl.Contains("/Admin/Seguranca/Usuario/UsuarioMudarSenhaPage.aspx")) &&
                    (Session["MudarSenha"] != null && Convert.ToBoolean(Session["MudarSenha"]) == true))
                {
                    this.Redirect("~/Admin/Seguranca/Usuario/UsuarioMudarSenhaPage.aspx");
                }

                SetSiteMapDataSource();
            }
        }

        private void SetSiteMapDataSource()
        {
            NavigationMenu.DataSource = GetDataSource();
            NavigationMenu.DataBind();
        }

        private XmlDataSource GetDataSource()
        {
            XmlDataSource oXmlDataSource = new XmlDataSource();
            oXmlDataSource.XPath = "siteMap/siteMapNode";
            string fileName = Server.MapPath("~/Admin/_SiteMap/" + this.Page.User.Identity.Name + ".sitemap");

            if (!File.Exists(fileName))
            {
                string path = Server.MapPath("~/Admin/_SiteMap/");
                new UsuarioBusiness2().GerarXmlSiteMap(path, UsuarioBusiness2.Create(this.UsuarioId));
            }

            oXmlDataSource.DataFile = fileName;

            oXmlDataSource.DataBind();

            return oXmlDataSource;
        }
    }
}

AdminBase.Master

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="AdminBase.master.cs" Inherits="Devcompy.ClientWebForms.Admin.AdminBase" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br">
<head id="Head1" runat="server">
    <meta name="robots" content="noindex, nofollow" />

    <title>Devcompy40</title>
    <link href="~/Styles/Admin/Site.css" rel="stylesheet" type="text/css" />
    <link href="~/Styles/Admin/Devcompy.css" rel="stylesheet" type="text/css" />

    <script src="<%= Page.ResolveUrl("~/Scripts/jquery-2.1.1.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/autoNumeric-1.7.5.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.maskedinput.js") %>" type="text/javascript"></script>

    <%--<script src="<%= Page.ResolveUrl("~/Scripts/jquery.cookies.2.2.0.min.js") %>" type="text/javascript"></script>

    <script src="<%= Page.ResolveUrl("~/Scripts/minified/jquery.ui.core.min.js") %>" type="text/javascript"></script>

    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.core.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.widget.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.position.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.menu.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.autocomplete.js") %>" type="text/javascript"></script>


    <script src="<%= Page.ResolveUrl("~/Scripts/minified/jquery.ui.widget.min.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/minified/jquery.ui.button.min.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/minified/jquery.ui.tabs.min.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/minified/jquery.ui.datepicker.min.js") %>" type="text/javascript"></script>

        <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.position.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/jquery.ui.spinner.js") %>" type="text/javascript"></script>--%>

    <script src="<%= Page.ResolveUrl("~/Scripts/jquery-ui-1.10.4.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("~/Scripts/Devcompy.js") %>?<%= new Random().Next() %>" type="text/javascript"></script>

    <link href="<%= Page.ResolveUrl("~/Styles/themes/base/jquery.ui.all.css") %>" rel="stylesheet" type="text/css" />

    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body runat="server">
    <form id="form1" runat="server" clientidmode="Static">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:HiddenField ID="vsKey" runat="server" />
        <input type="hidden" id="hidLastTab" value="0" name="hidLastTab" />
        <div class="page">
            <div class="header">
                <asp:ContentPlaceHolder ID="HeaderBodyContent" runat="server" />
            </div>
            <div class="main">
                <asp:ContentPlaceHolder ID="MainContent" runat="server" />
            </div>
            <div class="footer">
                <asp:ContentPlaceHolder ID="FooterContent" runat="server" />
            </div>
        </div>
    </form>
    <asp:ContentPlaceHolder ID="ScriptContent" runat="server">
    </asp:ContentPlaceHolder>
</body>
</html>

AdminBase.Master.cs

using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using Devcompy.Lib;
using Devcompy.Lib.Validations;
using Devcompy.Repositories.Web.Base;
using Devcompy.Models.Entities.Segurancas;
using Devcompy.Repositories.Business2.Seguranca;

namespace Devcompy.ClientWebForms.Admin
{
    public partial class AdminBase : DevcompyMasterPage
    {

        protected override void PageLoad()
        {
            if (!Request.RawUrl.Contains("/Admin/Login/LoginPage.aspx"))
            {
                if (this.UsuarioId == 0)
                {
                    FormsAuthentication.SignOut();
                    FormsAuthentication.RedirectToLoginPage();
                }
            }

            if (!this.IsPostBack)
                VerificarPermissoes();
        }

        private void VerificarPermissoes()
        {
            //DevcompyLib.IsLocalIpAddress();
            if (!this.IsPostBack && this.UsuarioId != 1)
            {
                if ((!Request.RawUrl.Contains("/Admin/Seguranca/Usuario/UsuarioMudarSenhaPage.aspx")) &&
                    (Session["MudarSenha"] != null && Devcompy2.ToBoolean(Session["MudarSenha"].ToString(), false) == true))
                {
                    this.Redirect("~/Admin/Seguranca/Usuario/UsuarioMudarSenhaPage.aspx");
                }

                if (!Request.RawUrl.Contains("/Admin/Default.aspx") &&
                    !Request.RawUrl.Contains("/Admin/Login/LoginPage.aspx") &&
                    !Request.RawUrl.Contains("/Admin/Seguranca/Usuario/UsuarioMudarSenhaPage.aspx") &&
                    !Request.RawUrl.Contains("/Admin/WinForms") &&
                    !Request.RawUrl.Contains("/Admin/Errors"))
                {

                    SiteMapNode currentNode = SiteMap.CurrentNode;

                    if (currentNode != null && !String.IsNullOrWhiteSpace(currentNode.ResourceKey) && currentNode.ParentNode != null)
                    {

                        UsuarioSiteMapEntity usuarioSiteMap = UsuarioSiteMapBusiness.CreateResourceKey(currentNode.ResourceKey, this.UsuarioId);

                        if (usuarioSiteMap != null)
                        {
                            if (!usuarioSiteMap.Access)
                            {
                                Page.ShowMessage(Mensagens.AcessoNegadoMenu(usuarioSiteMap.SiteMap.TitleParent), "~/Admin/Default.aspx");

                            }
                            else if (!usuarioSiteMap.Usuario.Ativo)
                            {
                                HttpContext.Current.Session.Remove("UsuarioId");
                                FormsAuthentication.SignOut();
                                FormsAuthentication.RedirectToLoginPage();
                            }
                            else
                            {
                                if (String.IsNullOrWhiteSpace(this.Page.Title))
                                {
                                    this.Page.Title = "Devcompy 40 - " + usuarioSiteMap.SiteMap.TitleParent;
                                }
                            }
                        }
                        else
                        {
                            Page.ShowMessage(Mensagens.PaginaNaoEncontrada(), "~/Admin/Default.aspx");


                        }
                    }
                    else
                    {
                        if (this.UsuarioId != 1)
                        {
                            Page.ShowMessage(Mensagens.PaginaNaoEncontrada(), "~/Admin/Default.aspx");
                        }
                    }
                }
            }
        }

        protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
        {
            if (e.Exception is DevcompyException)
            {
                Page.ShowMessage(e.Exception.Message);
            }
            else
            {
                new DevcompyException(e.Exception.Message, e.Exception);
                Page.ShowMessage("Ação Inesperada no Sistema <br />" + e.Exception.Message);
            }


        }
    }
}
    
asked by anonymous 10.06.2016 / 14:09

2 answers

0

The solution to my case was to return the AjaxControlToolkit version to a version that worked.

    
26.07.2016 / 21:01
0

Can not have <%% > when you try to add controls in runtime. To change the <%% > use Code Behind before using properties for the purpose like

this.Page.Title = "Ola Mundo";

or by adding the tags runat="server"

<div runtat="server" ID="myFirstControl"></div> 

and then in the code behind

myFirstControls.InnerHtml = "O meu texto aqui"; 
    
11.06.2016 / 20:34