Reply
Why won't my javascript work? ASP code blocking it?
Old 03-20-2009, 10:24 AM Why won't my javascript work? ASP code blocking it?
Novice Talker

Posts: 10
Trades: 0
I have one page in my entire site that the javascript won't work, I need it for the dropdown menu to work in IE6. I've made sure it's linked correctly, even tried putting it inline - nothing makes it work. Is there something in my ASP code that is preventing it from loading?? (I need p7exp.js to load)

Code of ASPX page:
Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb"  Inherits="sec.Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Spartan Chassis  |  Everything's Riding On It.</title>
<link rel="icon" href="../../../favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="../../../p7exp/p7exp.js"></script>
<link href="../../../sc.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>
<style>
#menuwrapper, #p7menubar ul a {height: 1%;}
a:active {width: auto;}
</style>
<![endif]-->
</head>
<body onload="P7_ExpMenu()">
Code of .vb page:
Code:
Imports System.Data.SqlClient
Imports System.Data
Imports System.Configuration.Configuration

Partial Public Class Login
    Inherits System.Web.UI.Page
#Region "Variables"
    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim strSql As String
#End Region

#Region "Events"
    ''' <summary>
    ''' things that happen when the page loads
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' if we already have a session("UserID") then redirect to correct page
        ' this means they are already logged in.
        If Session("UserID") Is Nothing Then
            ' nada
        Else
            If Session("UserID") > 0 Then
                ' go to the appropriate page for the usertype
                Select Case Session("UserTypeID")
                    Case 3  ' Admin
                        Response.Redirect("AdminMain.aspx")

                    Case 4  ' Supplier
                        Response.Redirect("SupplierMain.aspx")
                End Select
            End If
        End If


        Me.btnLogin.Attributes.Add("onClick", "return ValidateEntry();")
        Me.txtLogin.Focus()
    End Sub

    ''' <summary>
    ''' close the db connection if open
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        CloseSqlDB()
    End Sub

    ''' <summary>
    ''' go check the login and pw values for a match and determine if we have a admin or a supplier here
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Protected Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Try


            ' open up the database
            OpenSqlDb()

            ' go see if we have a match 
            strSql = "Select ID, UserTypeID, ChangePW " & _
                        " From UserInfo " & _
                        " Where LoginID = '" & Me.txtLogin.Text.Trim.Replace("'", "''") & "'" & _
                        " AND BINARY_CHECKSUM(Password) = BINARY_CHECKSUM('" & Me.txtPW.Text.Trim.Replace("'", "''") & "')" & _
                        " And Password = '" & Me.txtPW.Text.Trim.Replace("'", "''") & "'" & _
                        " AND Active = 1 and UserTypeID IN(3,4) "
            cmd.CommandText = strSql
            Dim myrdr As SqlDataReader = cmd.ExecuteReader

            Session("UserID") = ""
            Session("UserType") = ""
            Dim FoundOne As Boolean = False
            Dim ChangePW As Boolean = False
            While myrdr.Read
                ' assign the userid session variable
                Session("UserID") = myrdr("ID")
                ' assign the usertype session variable
                Session("UserTypeID") = myrdr("UserTypeID")
                ChangePW = myrdr("ChangePW")
                FoundOne = True
            End While
            myrdr.Close()

            If Not FoundOne Then
                Me.lblError.Text = "Invalid UserID / Password."
                Session("UserID") = 0
                Me.txtPW.Text = ""
                Me.txtPW.Focus()
                Exit Sub
            End If

            ' update the last logged in date
            strSql = "Update UserInfo Set LastLoggedInDate = GETDATE() Where ID = " & Session("UserID")
            cmd.CommandText = strSql
            cmd.ExecuteNonQuery()

            ' if the UserInfo.ChangePW flag is true - direct user to the ChangePW.aspx page
            If ChangePW Then
                Response.Redirect("ChangePW.aspx")
            End If

            ' go to the appropriate page for the usertype
            Select Case Session("UserTypeID")
                Case 3  ' Admin
                    Response.Redirect("AdminMain.aspx")

                Case 4  ' Supplier
                    Response.Redirect("SupplierMain.aspx")
            End Select
        Catch ex As Exception
            Me.lblError.Text = ex.Message
        End Try
    End Sub
#End Region
#Region "Subs"
    ''' <summary>
    ''' this routine will make the connection to the database
    ''' </summary>
    ''' <remarks></remarks>
    Protected Sub OpenSqlDb()
        Dim connstr As String = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        cmd = New SqlCommand
        conn = New SqlConnection(connstr)
        conn.Open()
        cmd.Connection = conn
    End Sub

    ''' <summary>
    ''' close the connection if it's open
    ''' </summary>
    ''' <remarks></remarks>
    Protected Sub CloseSqlDB()
        If conn.State = ConnectionState.Open Then
            conn.Close()
            conn.Dispose()
        End If
    End Sub
#End Region
#Region "Functions"
#End Region
End Class
LexieMSU08 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 03-20-2009, 03:24 PM Re: Why won't my javascript work? ASP code blocking it?
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
get rid of the ../../../path document relative addressing and use root relative instead.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-20-2009, 04:48 PM Re: Why won't my javascript work? ASP code blocking it?
Novice Talker

Posts: 10
Trades: 0
Done it. Still doesn't work.
LexieMSU08 is offline
Reply With Quote
View Public Profile
 
Old 03-20-2009, 04:53 PM Re: Why won't my javascript work? ASP code blocking it?
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
error messages?
URI?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-22-2009, 02:00 PM Re: Why won't my javascript work? ASP code blocking it?
Average Talker

Posts: 22
Name: adoc fish
Trades: 0
Why don't you try to debug the static version of the page? save it as HTML and then debug. Once that is doing what it should be doing, you can go back to the dynamic version and see what is different.

If it's a big page and difficult to debug, simplify the page by throwing out markup that doesn't affect your problem. The smallest file that contains the problem is usually the simplest to fix.
_coda_ is offline
Reply With Quote
View Public Profile
 
Old 03-23-2009, 11:09 AM Re: Why won't my javascript work? ASP code blocking it?
Novice Talker

Posts: 10
Trades: 0
Ok - Here is the deal - I am a web designer, I do not know anything about asp, debugging, and whatnot, and my developer will not help me on this. Is there a way around this? Has anyone had this same issue?
LexieMSU08 is offline
Reply With Quote
View Public Profile
 
Old 03-24-2009, 07:44 AM Re: Why won't my javascript work? ASP code blocking it?
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
without a URI we have no chance at all.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Why won't my javascript work? ASP code blocking it?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.12741 seconds with 13 queries