简体   繁体   English

对于我的其中一页上具有autopostback = true的任何内容,我收到“ Microsoft JScript运行时错误:对象不支持此属性或方法”错误

[英]I get a “Microsoft JScript runtime error: Object doesn't support this property or method” error for anything with autopostback=true on one of my pages

I have a .NET application with the following aspx code: 我有一个带有以下aspx代码的.NET应用程序:

<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default"%>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik"%>

<!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" >

<body>
<form id="form1" runat="server">

<asp:ToolkitScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ToolkitScriptManager>
<table>
<tr>
<td>
    <asp:RadioButtonList ID="rblTest" runat="server" AutoPostBack="True" 
        onselectedindexchanged="rblTest_SelectedIndexChanged">
        <asp:ListItem Text="1" Value="1"></asp:ListItem>
        <asp:ListItem Text="2" Value="2"></asp:ListItem>
    </asp:RadioButtonList>
</td>
<td>
    <asp:PlaceHolder ID="ph1" runat="server" Visible="False">
        Some text
    </asp:PlaceHolder>
</td>
</tr>
</table>
</form>
</body>
</html>

I then have a C# method as follows: 然后,我有一个C#方法,如下所示:

protected void rblTest_SelectedIndexChanged(object sender, EventArgs e)
{
    if (rblTest.SelectedValue == "2")
        ph1.Visible = true;
    else
        ph1.Visible = false;
}

Below is where the crash occurred. 以下是发生崩溃的地方。 It crashes any time I use a control that has autopostback=true. 每当我使用具有autopostback = true的控件时,它就会崩溃。 I use the same syntax on about 15 other forms and those all work just fine. 我在大约15种其他形式上使用了相同的语法,并且所有这些都很好用。 Am I missing a property somewhere or is there something wrong with my method? 我在某处缺少属性还是我的方法有问题? I originally had an UpdatePanel around the controls and I plan on adding it again, but I need to get the postback working first. 我最初在控件周围有一个UpdatePanel,我打算再次添加它,但是我需要首先使回发工作。

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Default'];
if (!theForm) {
    theForm = document.Default;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();             <-----Crashed at this line.
    }
}
//]]>
</script>

What am I missing or is there some common mistake that I may have made somewhere? 我错过了什么,或者我可能在某个地方犯了一些常见的错误? Thanks in advance for your help. 在此先感谢您的帮助。

Your __doPostBack script is trying to submit a form with id "Default" (see document.forms["Default"] line; yet your markup shows a form with id "form1" so it's clear why it doesn't work: the __doPostBack function is not finding the form and calling theForm.submit() fails. 您的__doPostBack脚本正在尝试提交ID为"Default"的表单(请参见document.forms["Default"]行;但是您的标记显示的表单为ID为"form1"的表单,因此很清楚为什么它不起作用: __doPostBack函数找不到表单,调用theForm.submit()失败。

You can attempt to fix it by renaming the form to use the id "Default" since I don't think you can control the way the __doPostBack script is generated. 您可以尝试通过重命名表单以使用ID "Default"来修复它,因为我认为您无法控制__doPostBack脚本的生成方式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method Microsoft JScript运行时错误:对象不支持属性或方法&#39;addEventListener&#39; - Microsoft JScript runtime error: Object doesn't support property or method 'addEventListener' Microsoft JScript运行时错误:对象不支持属性或方法“ val” - Microsoft JScript runtime error: Object doesn't support property or method 'val' Microsoft JScript运行时错误:对象不支持属性或方法“ validate” - Microsoft JScript runtime error: Object doesn't support property or method 'validate' 来自自动回发的错误:“ Microsoft JScript运行时错误:找不到成员。” - Error from autopostback: “Microsoft JScript runtime error: Member not found.” 运行时错误438。对象不支持此属性或方法 - Runtime error 438. Object doesn't support this property or method Microsoft JScript运行时错误:无法获取属性“样式”的值:对象为null或未定义 - Microsoft JScript runtime error: Unable to get value of the property 'style': object is null or undefined Microsoft JScript运行时错误:无法获取属性&#39;removeChild&#39;的值:对象为null或未定义 - Microsoft JScript runtime error: Unable to get value of the property 'removeChild': object is null or undefined 0x800a01b6 - JavaScript 运行时错误:对象不支持属性或方法“get_id” - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'get_id'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM