CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > migration_to_asp.net.migrating_from_asp.net_1.x_to_asp.net_2.0 Tags:
Item Type: NewsGroup Date Entered: 5/18/2005 11:20:43 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 12 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
Ahmed Shafi
Asp.Net User
Problem with Javascript after migrating to beta 25/18/2005 11:20:43 PM

0/0

Hi there,

I just started porting an app to beta 2 from 1.1 and I am having some problems with javascript on the page. It is a simple login page where a java script function posts the form when a button is pressed. But I get the following error when i double click on the "Done" icon at the bottom of the page:

'document.formLogin' is null or not an object

code: 0
The same page works fine on 1.1. I am running ASP.NET beta 2 on a virtual machine with an XP image on it

Here are the markup and code behind files:

markup :

<%@ Register TagPrefix="uc1" TagName="Header" Src="UserControls/Header.ascx" %>
<%@ Page language="c#" Inherits="SECO.Login" CodeFile="Login.aspx.cs" %>
<%@ Register TagPrefix="uc1" TagName="Footer" Src="UserControls/Footer.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <TITLE>Texas Energy Partnership Reporting Database</TITLE>
        <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <LINK href="CSS/main_style.css" type="text/css" rel="stylesheet">
            <script src="js/SECO.js"> </script>
            <script src="js/common.js"> </script>
            <SCRIPT language="JavaScript">
           
            // Input param : emailElem - form element expecting an email address
            // Description : Checks to see if element contains a valid email address.
            function isValidEmail(emailElem){
            validRegExp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
            strEmail = emailElem.value;

            // search email text for regular exp matches
            if ((strEmail.search(validRegExp) == -1) || (isblank (emailElem)) )
            {
                // set focus on the element we just checked
                emailElem.focus();
                return false;
            }
            return true;
            }
               
           
            // JS Function to validate the form data
                function ValidateForm ()
                {
               
//                        if (isblank (document.formLogin.txtUserName)
//                            ||
//                            !(isValidEmail(document.formLogin.txtUserName))
//                            )
//                        {
//                            alert ('Please enter a valid email address');
//                            document.formLogin.txtUserName.focus();
//                            return false;
//                        }
//                        else
//                        {
                            document.formLogin.submit();
//                        }
                }
            </SCRIPT>
    </HEAD>
    <BODY text="#000000" bgColor="#ffffff" onload="CheckBrowser();MM_preloadImages('/menu/profile_menu_over.jpg','/menu/project_menu_over.jpg','/menu/reporting_menu_over.jpg','/menu/library_menu_over.jpg','/menu/get_help_menu_over.jpg')">
        <DIV id="toolTipLayer" style="VISIBILITY: hidden; POSITION: absolute"></DIV>
        <form id="formLogin" name="formLogin" method="post" runat="server">
            <uc1:header id="Header1" runat="server"></uc1:header>
            <TABLE cellSpacing="0" cellPadding="0" width="755" border="0">
                <TBODY>
                    <TR>
                        <TD noWrap height="34">
                            <TABLE cellSpacing="0" cellPadding="0" width="755" border="0">
                                <TBODY>
                                    <TR>
                                        <TD class="title">Welcome to the Texas Energy Partnership Reporting System
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD noWrap height="20"></TD>
                                    </TR>
                                    <TR>
                                        <TD class="text">The revised, online reporting system enables cities, counties, and
                                            other political institutions to report annual Texas Emissions Reduction Plan
                                            energy savings, as required by <a href="http://tmpwebesl.tamu.edu/sb5/index.html" target="_blank">
                                                Texas Health &amp; Safety Code, Section 388.005 (SB5, 77th Legislature).</a>&nbsp;
                                            The new online data reporting system has been updated to allow editing,
                                            updating, and printing capabilities, as well as an option to apply for
                                            emissions crediting under the State Implementation Plan (SIP).
                                            <P></P>
                                            <p class="text" align="left">If you reported on-line for the calender year of 2002
                                                or before, please re-register to obtain a new password.</p>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD noWrap height="20"></TD>
                                    </TR>
                                    <TR>
                                        <TD class="text-bold" noWrap height="25">If you are new to our system, <A href="register.aspx">
                                                Please Register</A>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD noWrap height="161">
                                            <div align="left">
                                                <table cellSpacing="0" cellPadding="3" width="409" align="center" border="0">
                                                    <tr>
                                                        <td noWrap colSpan="4" height="15"></td>
                                                    </tr>
                                                    <tr>
                                                        <td noWrap colSpan="4" height="16">
                                                            <div align="center"><IMG height="1" src="graphic/gray_dot.gif" width="270">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr vAlign="middle">
                                                        <td noWrap align="center" width="127" rowSpan="3"><IMG height="126" src="graphic/LEFT_login.jpg" width="241"></td>
                                                        <td noWrap align="center" width="127" height="51">
                                                            <div align="left"><label class="text-bold" for="label"><IMG height="7" src="graphic/arrow_blue.gif" width="8">Email Address &nbsp;</label>
                                                            </div>
                                                        </td>
                                                        <td noWrap align="center" width="137" height="51">
                                                            <asp:TextBox id="txtUserName" runat="server" Width = "130"></asp:TextBox></td>
                                                        <td noWrap align="center" width="137" rowSpan="3"><IMG height="126" src="graphic/RIGHT_login.jpg" width="239"></td>
                                                    </tr>
                                                    <tr vAlign="middle">
                                                        <td noWrap align="center" height="67">
                                                            <div align="left"><label class="text-bold" for="label2"><IMG height="7" src="graphic/arrow_blue.gif" width="8">Password &nbsp;</label>
                                                            </div>
                                                        </td>
                                                        <td noWrap align="center" height="67"><input class="NormalTextBox" id="label2" style="WIDTH: 130px" type="password" size="15"
                                                                name="txtPassword">
                                                        </td>
                                                    </tr>
                                                    <tr vAlign="middle">
                                                        <td noWrap align="center" height="25">
                                                            <div align="left"><span class="Normal"><label class="text-bold" for="_ctl0:_ctl6:_ctl0:chkCookie"></label>
                                                                </span></div>
                                                        </td>
                                                        <td noWrap align="center" height="25"><span class="Normal"><asp:checkbox id="chkRemember" runat="server"></asp:checkbox>&nbsp;
                  <label class="subHeading-bold-blue" for="label3">Remember Login</label> </span></td>
                                                    </tr>
                                                    <tr>
                                                        <td align="center" colSpan="4">
                                                            <div align="center"><IMG height="1" src="graphic/gray_dot.gif" width="270"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td noWrap align="center" colSpan="4" height="15">
                                                            <asp:label id="lblMessage" runat="server" CssClass="errorMark" Height="2px" Width="448px"></asp:label></td>
                                                    </tr>
                                                    <tr>
                                                        <td align="center" colSpan="4">
                                                            <div align="center">
                                                                &nbsp;<input id="btnLogin" onclick="ValidateForm();" type="button" value="Login">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD align="left"><span class="text-bold">Lost your password?</span>
                                            <A href="passwordLost.aspx">Click here</A>
                                        </TD>
                                    </TR>
                                </TBODY></TABLE>
                        </TD>
                    </TR>
                    <TR>
                        <TD>&nbsp;</TD>
                    </TR>
       
            <TR>
                <TD><IMG height="1" src="graphic/dot_line.gif" width="755"></TD>
            </TR>
       
                </TBODY></TABLE>
            </form>
       
       
        <uc1:footer id="Footer1" runat="server"></uc1:footer>
    </BODY>
</HTML>

---------------CODE BEHIND----------------------------------


using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using Ecalc.Utils.ExceptionEcalc;

namespace SECO
{

    /// <summary>
    /// Summary description for WebForm1.
    /// </summary>
    public partial class Login : System.Web.UI.Page
    {
        private String ESRPage = "IntroText.aspx";
        private String selfUrl = "Login.aspx";
        private String errorPage = "Error.aspx";
        private String msgPswdMismatch = "User ID and Password do not match";

        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            if (Session["Message"] != null)
                lblMessage.Text = Session["Message"].ToString();
            else
                lblMessage.Text = "";

            //btnLogin.Attributes.Add ("onClick", "ValidateForm();");

            // read from cookie
            HttpCookie savedCookie = Request.Cookies["SECO_User"];
            String uNameSaved;
            if ((savedCookie != null) && (savedCookie.HasKeys))
            {
                uNameSaved = savedCookie.Values["userName"];
                txtUserName.Text = uNameSaved;
            }


            if (Page.IsPostBack)
            {
                ProcessForm();
            }
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {

        }
        #endregion

        private void ProcessForm()
        {
            // temp code for validating user login (assumes unencrypted password)

            String nextPage = selfUrl;
            String message = " ";
            UserInfo userInf = new UserInfo();
            WebUtils wu = new WebUtils();

            // default status = error
            enumLoginStatus loginStatus = enumLoginStatus.INTERNAL_ERROR;

            String email = Request.Form.Get("txtUserName");

            if ((email == null) || (email.Trim() == ""))
            {
                // this should never happen, because email is validated on client side
                message = "Please provide a valid email address.";
                nextPage = selfUrl;
            }
            else
            {
                email = email.Trim();
                //bool isSecureLogin = false;
                String enteredPswd = Request.Form.Get("txtPassword");

                // set cookie values
                if (chkRemember.Checked)
                {
                    HttpCookie ckUser = new HttpCookie("SECO_User");
                    // Tried using ckUser.Expires = DateTime.MaxValue, but that doesn't work!! 
                    ckUser.Expires = DateTime.Now.AddYears(1);
                    ckUser.Values.Add("userName", email);
                    Response.Cookies.Add(ckUser);
                }

                loginStatus = userInf.ValidateUser(email, enteredPswd);


                // According to login status, determine next action
                switch (loginStatus)
                {
                    case enumLoginStatus.USER_AUTHENTICATED:
                        message = "";
                        nextPage = ESRPage;

                        DoLogin(email);

                        break;

                    case enumLoginStatus.PASSWORD_MISMATCH:
                        if (Session["LOGIN_ATTEMPTS"] == null)
                        {
                            Session["LOGIN_ATTEMPT_EMAIL"] = email;
                            Session["LOGIN_ATTEMPTS"] = 1;
                            message = msgPswdMismatch;
                        }
                        else
                        {
                            try
                            {
                                int attempts = Convert.ToInt32(Session["LOGIN_ATTEMPTS"]) + 1;
                                Session["LOGIN_ATTEMPTS"] = attempts;
                                if ((Session["LOGIN_ATTEMPT_EMAIL"].ToString() == email) && (attempts > 3))
                                {
                                    message = "You have exceeded the maximum number of login attempts allowed." +
                                        "  Please contact the SECO Administrator, or reset your password.";
                                    wu.sendEmailToAdmin(EmailReasons.MAX_LOGIN_ATTEMPTS,
                                        "Maximum login attempts exceeded for user " + email, "");
                                }
                                else
                                {
                                    message = msgPswdMismatch;
                                }
                            }
                            catch (Exception ex)
                            {
                                String a = ex.Message;
                                // send error email to sys admin    
                                ExceptionPublisher.Publish(ex);
                            }

                        }
                        nextPage = selfUrl;
                        break;

                    case enumLoginStatus.USER_NOT_EXIST:
                        message = "This email ID does not exist in our database. " +
                            " Please register yourself as a new user. ";
                        nextPage = selfUrl;
                        break;

                    case enumLoginStatus.INTERNAL_ERROR:
                        message = "Internal Error.";
                        nextPage = errorPage;
                        break;

                    case enumLoginStatus.DB_ERROR:
                        message = "Sorry, we are currently experiencing a heavy load on our database."
                            + " Please try to log in later.";
                        nextPage = errorPage;
                        break;
                }
            }
            Session["Message"] = message;
            Server.Transfer(nextPage);
        }

        protected void DoLogin(String email)
        {
            UserInfo userInf = new UserInfo();
            userInf = userInf.GetUserDetails(email);
            Session["USER_INFO"] = userInf;

            // add a temp cookie to indicate login
            HttpCookie ckLogin = new HttpCookie("SECO_Login");
            ckLogin.Values.Add("Login" + email, "Y");
            ckLogin.Expires = DateTime.Now.AddMinutes(60);
            Response.Cookies.Add(ckLogin);


        }      
    }
}





twgathings
Asp.Net User
Re: Problem with Javascript after migrating to beta 25/19/2005 4:19:06 PM

0/0

i haven't been using 2.0, but for some reason, 2.0 doesn't emit the name attribute of form. by using document.Form1 you are referring to the form by name. you could try either of these...not sure which works per browser compatibility.

document.forms[0] or document.getElementById("Form1")

if i were you, i would look at how microsoft references the form by peeking into the __doPostBack function, if that is what it's still called. you can see this in the html output from your page.


cheers :: thomas
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Web Application Development with PHP 4.0: contains official zend API documentation Authors: Tobias Ratschiller, Till Gerken, Pages: 416, Published: 2000
Dr. Tom Shinder's Configuring ISA Server 2004: Written by the Industry's Most Trusted Source on ISA Server, Microsoft " Most Valuable Professionls" Tom and Deb Shinder. Provides a Clear Migration Path from Earlier Versions of ISA Server. Covers All New Features, Including Advanced Application-Layer Firewalls, VPN's , and Web Cache Solutions Authors: Thomas W. Shinder, Debra Littlejohn Shinder, Martin Grasdal, Pages: 608, Published: 2004

Web:
AIR:Migration - Adobe Labs Adobe AIR Beta 2 Migration Notes. September 30, 2007 .... Some calls to the JavaScript eval() function and changes to innerHTML properties of DOM object ...
Session Timeout Problem After Migrating to .net 3.5 : asp.net vb ... Session Timeout Problem After Migrating to .net 3.5 ... 2, Alert user before session timeout · JavaScript. 3, Timeout expired -- VERY URGENT, PLEASE ...
ASP.NET AJAX 1.0 Beta 2 Release - ScottGu's Blog The issue with Beta2 and the RC is that IE 6 SP1 has problems handling compressed JavaScript files (which ASP.NET AJAX send back by default). ...
DotNetSlackers: Migrating from the VS2008 Beta2 LINQ-to-SQL to RTM Mar 16, 2008 ... While I'm on migration, here are some pointers for stuff I had to do when migrating my LINQ-to-SQL project from VS2008 Beta2 to RTM. ...
Migrating from Flex Builder 3 Beta 1 to Flex Builder 3 Beta 2 at ... Flex Builder 3 beta 2 comes with the Flex 2.0.1 Hotfix 3 and Flex 3 M3 ... 2 Responses to “Migrating from Flex Builder 3 Beta 1 to Flex Builder 3 Beta 2” ...
Migrating from .NET 1.1 to .NET 3.5 with Visual Studio 2008 - A ... Note that I am migrating from 2003 visual studio to 2008 Beta 2. ... I got a weird error after migrating the 1.1 version of the microsoft ui process ...
Mozilla Firefox 2 Beta 2 Release Notes This list covers some of the known problems with Firefox 2 Beta 2. ... This was fixed after the deadline for Firefox 2 Beta 2 and will not happen in recent ...
VS.NET 2005 Migration problem datagrid too after switching from ASP.NET Beta 2.0 to to production ... Posts: 2 . Question How to solve the javascript error ...
AS2 to AS3 migration problems [Archive] - FlashMove Forum [Archive] AS2 to AS3 migration problems ActionScript 3.0. ... i spent 2 weeks trying to find the AS2 solution to get cookies to flash. ...
Problems with migrating Cardspace cards between computers - Stack ... This is a public beta. Found a bug? Want to make a feature request? stackoverflow.uservoice. ... Can I get a user’s OpenID SHH secret with Javascript only? ...




Search This Site:










who's got the best price and value for dedicated servers?

webuivalidation.js

how many roles?

treeview "table of content" skin expand/collapse

locked out after using database explorer

theme won't work

problem to create a new windows user from appliaction level in win 2003 server

themes not being applied

expose properties of user control to visual studio properties toolbox

how to install a changed module on a live production server

bug in visual studio 2005 during migration.

good alternative to godaddy?

installed!! now what?

nuke sql on local--newbie question

cannot edit or delete links

.net dll from asp

please help with installing and running sample aspx

bug [resource not found] - no login.aspx page exists after install completes with no errors

oh no friday 13th strikes (please help!!)

"visual web developer does not support creating web sites on a sharepoint web server"

moving install confuses passwords

ide reformatting html switching from source to design and back

how to implement registered user(s) predefine role when user register?

forward credentials from asp.net web-application to asp.net web-service

javascript and master page problem

loginview control's viewchanged event does not fire

upgrade failed following the readme.txt instructions...

where does asp.net 2.0 insert a anonymous user? thanks

dnn on intranet

adding controls in response to postbacks

 
All Times Are GMT