简体   繁体   中英

Microsoft Jscript runtime error on page redirect - asp.net and javascript

I have two pages in my .net website

One is the default.aspx and the other is the login.aspx

default.aspx is just a blank page, which is used for redirecting to the login.aspx page

In login.aspx, I have a textbox and a javascript onfocus event on that texbox. (There is only an alert method in the javascript function)

If I start the login.aspx page from Visual Studio, the page opens up fine in IE and the javascript executes fine on focussing the cursor on the texbox.

If I run the default.aspx from Visual Studio, the page gets redirected to login.aspx. But, the javascript does not execute in this case. ie in this case, I get the error - Microsoft jscript runtime error - permission denied'

Not sure what the issue is. If you guys would be able to point anything here, it would be great!!

BTW,

It works fine if debugging is disabled in web.config. Only if debugging is enabled, does this issue crop up.

In firefox, it works absolutely fine. The issue is only with IE.

Thanks!!!

Please find my code below. Thanks

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>

    </div>
  </form>
</body>
</html>

Default.aspx.vb

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Session("UserId") Is Nothing Then
        Response.Redirect("login.aspx")
    End If
End Sub
End Class

login.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="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 runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
function resetFormField(){alert("OK");}
</script>

</head>
<body>
  <form id="form1" runat="server">
  <div>
    <asp:TextBox ID="txtloginemailId" runat="server" Columns="25">                
    </asp:TextBox>
  </div>
  </form>
</body>
</html>

login.aspx.vb

Partial Class login
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Me.txtloginemailId.Attributes.Add("onfocus", "resetFormField(this);")
End Sub
End Class

(Session has not been set anywhere. So, the redirection would always take place)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM