vs2005
前台:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton1" runat="server"
Text="点击" OnClick="LinkButton1_Click"></asp:LinkButton></div>
</form>
</body>
</html>后台:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;namespace WebApplication2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void LinkButton1_Click(object sender, EventArgs e)
{
TextBox1.Text = "123";
}
}
}
点击linkbutton1 后 后台无相应,页面左下角出现黄色标记,打开后显示
行:25
字符:9
错误:‘theform__eventtarget 为空或不是对象’
代码:0
前台:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton1" runat="server"
Text="点击" OnClick="LinkButton1_Click"></asp:LinkButton></div>
</form>
</body>
</html>后台:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;namespace WebApplication2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void LinkButton1_Click(object sender, EventArgs e)
{
TextBox1.Text = "123";
}
}
}
点击linkbutton1 后 后台无相应,页面左下角出现黄色标记,打开后显示
行:25
字符:9
错误:‘theform__eventtarget 为空或不是对象’
代码:0
{}
else
{
}
-----
先判断下theform__eventtarget是否为空在操作
Text="点击" OnClick="LinkButton1_Click" target="self"> </asp:LinkButton>
试下LinkButton要设置target属性的
还有一种方法就是写入一段脚本:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
同时添加进入:
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
检查一下form有没有嵌套
看帖一定要回的,分也一定要接的 ^_^
****************************************************************[/align]
和这个没关系Inherits="WebApplication2._Default" 这个和 _Default
对应就可以了
表单元素是不可以嵌套的
不过是linkbutton 点击后跳转到其它页面的
找了半天就是找不出问题 最后我感觉有可能是被防火墙或杀毒软件问题
于是就把卡巴关了 关了之后就好了
你试试看呢 杀毒软件有时也有影响呢
楼上的兄弟,杀毒软件全部关闭也不行。
网站的话去掉 namespace 试试