Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Ajax quits working after login, ScriptManager?

$
0
0

I just copied my website over to a new solution.

I got everything up and running, but when I login, my hover menus stop working.  I checked and when a user is not logged in, ajax is working.

I'm thinking it has something to do with the Master Page ScriptManager.  Also, I notice my solution doesn't recognize System.Web.UI.  I have to import it for it to work.

I checked my assemblies and System.Web.Extentions is there.

Here is my master page markup and code:

<%@ Master Language="VB" AutoEventWireup="true" CodeBehind="Site.master.vb" Inherits="hsc.SiteMaster" %><%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %><%@ Import Namespace="toc" %><%@ Import Namespace="Microsoft.AspNet.Identity" %><!DOCTYPE html><html lang="en"><head runat="server"><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><asp:PlaceHolder runat="server"><%: Scripts.Render("~/bundles/modernizr") %></asp:PlaceHolder><webopt:bundlereference runat="server" path="~/Content/css" /><link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /></head><body><form runat="server"><asp:ScriptManager runat="server"><Scripts><%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%><%--Framework Scripts--%><asp:ScriptReference Name="MsAjaxBundle" /><asp:ScriptReference Name="jquery" /><asp:ScriptReference Name="bootstrap" /><asp:ScriptReference Name="respond" /><asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" /><asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" /><asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" /><asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" /><asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" /><asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" /><asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" /><asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" /><asp:ScriptReference Name="WebFormsBundle" /><%--Site Scripts--%></Scripts></asp:ScriptManager><div class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" runat="server" href="~/">HSC</a></div><div class="navbar-collapse collapse"><ul class="nav navbar-nav"><li><a runat="server" href="~/Home">Home</a></li><li><a runat="server" href="~/Profiles">Profiles</a></li><li><a runat="server" href="~/Contact">Contact</a></li><li><a runat="server" href="~/About">About</a></li><li><div class="sMDate"><asp:Label ID="Label126" runat="server" ForeColor="Silver"></asp:Label></div></li></ul><asp:LoginView runat="server" id="LoginView1" ViewStateMode="Disabled"><AnonymousTemplate><ul class="nav navbar-nav navbar-right"><li><a runat="server" href="~/Account/Register" style="color: red;">Register</a></li><li><a runat="server" href="~/Account/Login" style="color: green;">Log in</a></li><li><asp:ImageButton ID="Image3" runat="server" AlternateText="IMAGE" PostBackUrl="~/Account/Login.aspx" Class="sMImg" Height="35px" ImageUrl='~/Images/tocmodel2.gif' ToolTip="Sign In!" Width="35px" ValidationGroup="reggate" /></li></ul></AnonymousTemplate><LoggedInTemplate><ul class="nav navbar-nav navbar-right"><li><a runat="server" href="~/Account/Manage" title="Manage your account" style="color:green">Hello, <%: Context.User.Identity.GetUserName()  %>!</a></li><li><asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="Id,UserName" DataSourceID="SqlDataSource2" GridLines="None" PageSize="1" ShowHeader="False"><Columns><asp:TemplateField HeaderText="Your Settings" SortExpression="UserName"><ItemTemplate><li><asp:Image ID="Image3" runat="server" AlternateText='<%# Bind("lastName")%>' CssClass="sMImg" Enabled='<%# Bind("ImgID") %>' 
                                            Height="35px" ImageUrl='<%# FormatURL11(DataBinder.Eval(Container.DataItem, "ImgID")) %>' onerror="this.src='images/tocmodel2.gif'" 
                                            ToolTip='<%# Bind("firstName")%>' Width="35" /></li><ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="Image3" PopupControlID="Panel1" PopupPosition="Left" OffsetY="-6" OffsetX="-5"></ajaxToolkit:HoverMenuExtender><asp:Panel ID="Panel1" runat="server" CssClass="SMHover"><li><asp:HyperLink ID="HyperLink6" runat="server" Text="Profile" NavigateUrl='<%# Eval("Id", "profile.aspx?Id={0} ") %>'></asp:HyperLink><a runat="server" href="~/Account/Settings" title="Manage your settings" style="color:green;width:75px;">Settings</a><asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Exit" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" /></li></asp:Panel></ItemTemplate></asp:TemplateField></Columns><PagerSettings Visible="False" /></asp:GridView><asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" 
    DeleteCommand="DELETE FROM [AspNetUsers] WHERE [Id] = @Id AND [UserName] = @UserName" 
    InsertCommand="
      INSERT INTO [AspNetUsers] ([URL], [firstName], [UserName]) VALUES (@firstName, @URL, @UserName)" 
    SelectCommand="SELECT Id, firstName, lastName, Quote, Sign, URL, zCode, UserName, Image, ImgID FROM dbo.AspNetUsers WHERE (UserName = @UserName)" 
    UpdateCommand="
      UPDATE [AspNetUsers] SET [firstName] = @firstName, [lastName] = @lastName, 
= @Quote, [Sign] = @Sign, [URL] = @URL, [zCode] = @zCode, [UserName] = @UserName WHERE [Id] = @Id AND Username = @UserName" OnDeleting="SqlDataSource1_Deleting" OnInserting="SqlDataSource1_Inserting" OnSelecting="SqlDataSource1_Selecting" OnUpdating="SqlDataSource1_Updating"><DeleteParameters><asp:Parameter Name="Id" Type="String" /><asp:Parameter Name="UserName" Type="String" /></DeleteParameters><InsertParameters><asp:Parameter Name="firstName" /><asp:Parameter Name="URL" Type="String" /><asp:Parameter Name="UserName" Type="String" /></InsertParameters><SelectParameters><asp:Parameter Name="UserName" Type="String" /></SelectParameters><UpdateParameters><asp:Parameter Name="firstName" Type="String" /><asp:Parameter Name="lastName" Type="String" /><asp:Parameter Name="Quote" Type="String" /><asp:Parameter Name="Sign" Type="String" /><asp:Parameter Name="URL" Type="String" /><asp:Parameter Name="zCode" Type="String" /><asp:Parameter Name="UserName" Type="String" /><asp:Parameter Name="Id" Type="String" /></UpdateParameters></asp:SqlDataSource></li></ul></LoggedInTemplate></asp:LoginView></div></div></div><div class="container body-content"><asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder><hr /><footer class="tocCFooter"><p>&copy; <%: DateTime.Now.Year %> - GSpotProd</p></footer></div></form></body></html>
Imports Microsoft.AspNet.Identity
Imports System.Web.Providers.Entities
Imports System.Data.Common

Public Class SiteMaster
    Inherits MasterPage
    Private Const AntiXsrfTokenKey As String = "__AntiXsrfToken"
    Private Const AntiXsrfUserNameKey As String = "__AntiXsrfUserName"
    Private _antiXsrfTokenValue As String

    Protected Sub Page_Init(sender As Object, e As EventArgs)
        ' The code below helps to protect against XSRF attacks
        Dim requestCookie = Request.Cookies(AntiXsrfTokenKey)
        Dim requestCookieGuidValue As Guid
        If requestCookie IsNot Nothing AndAlso Guid.TryParse(requestCookie.Value, requestCookieGuidValue) Then
            ' Use the Anti-XSRF token from the cookie
            _antiXsrfTokenValue = requestCookie.Value
            Page.ViewStateUserKey = _antiXsrfTokenValue
        Else
            ' Generate a new Anti-XSRF token and save to the cookie
            _antiXsrfTokenValue = Guid.NewGuid().ToString("N")
            Page.ViewStateUserKey = _antiXsrfTokenValue

            Dim responseCookie = New HttpCookie(AntiXsrfTokenKey) With { _
                 .HttpOnly = True, _
                 .Value = _antiXsrfTokenValue _
            }
            If FormsAuthentication.RequireSSL AndAlso Request.IsSecureConnection Then
                responseCookie.Secure = True
            End If
            Response.Cookies.[Set](responseCookie)
        End If

        AddHandler Page.PreLoad, AddressOf master_Page_PreLoad
    End Sub

    Protected Sub master_Page_PreLoad(sender As Object, e As EventArgs)
        If Not IsPostBack Then
            ' Set Anti-XSRF token
            ViewState(AntiXsrfTokenKey) = Page.ViewStateUserKey
            ViewState(AntiXsrfUserNameKey) = If(Context.User.Identity.Name, [String].Empty)
        Else
            ' Validate the Anti-XSRF token
            If DirectCast(ViewState(AntiXsrfTokenKey), String) <> _antiXsrfTokenValue OrElse DirectCast(ViewState(AntiXsrfUserNameKey), String) <> (If(Context.User.Identity.Name, [String].Empty)) Then
                Throw New InvalidOperationException("Validation of Anti-XSRF token failed.")
            End If
        End If
    End Sub

    Protected Sub SqlDataSource1_Selecting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Protected Sub SqlDataSource1_Inserting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Protected Sub SqlDataSource1_Updating(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Protected Sub SqlDataSource1_Deleting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Private Sub AssignUserName(parameters As DbParameterCollection)
        parameters("@UserName").Value = HttpContext.Current.User.Identity.Name
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If (HttpContext.Current.User.Identity.IsAuthenticated) Then
            Dim User As String = HttpContext.Current.User.Identity.Name
        End If

        'Dim UO As System.Web.UI.WebControls.Label = DirectCast(LoginView1.FindControl("UO"), System.Web.UI.WebControls.Label)

        'Put user code to initialize the page here


        Dim timeZoneInfo__1 As TimeZoneInfo
        Dim dateTime__2 As DateTime
        'Set the time zone information to US Mountain Standard Time 
        timeZoneInfo__1 = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")
        'Get date and time in US Mountain Standard Time 
        dateTime__2 = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo__1)
        'Print out the date and time
        Label126.Text = (dateTime__2.ToString("MM/dd/yy hh:mm:ss tt"))
    End Sub

    'Public Function FormatDate(ByVal input As DateTime) As Object
    '   Return [String].Format("{0:MM/dd/yy}", input)
    'End Function

    Protected Sub Unnamed_LoggingOut(sender As Object, e As LoginCancelEventArgs)
        Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie)
    End Sub

    Function FormatURL11(ByVal strArgument As String) As String
        Return ("getImage.aspx?ImgID=" & strArgument)
    End Function

End Class




Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>