未将对象引用设置到对象的实例,请问如何解决
anya 2006-07-07 11:16:43 做了一个特效菜单,其中html语言为:
<%@ Page language="c#" Codebehind="a.aspx.cs" AutoEventWireup="false" Inherits="x.a" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>css菜单演示</title>
<style type="text/css">
<!--
*{margin:0;padding:0;border:0;}
body {
font-family: arial, 宋体, serif;
font-size:12px;
}
#nav {line-height: 24px; list-style-type: none;}
#nav a {display: block; width: 80px; text-align:center;}
#nav a:link {color:#000000; text-decoration:none;}
#nav a:visited {color:#000000;text-decoration:none;}
#nav a:hover {color:#64B15E;text-decoration:none;font-weight:bold;}
#nav li { float:right; width: 80px; background:#FAFBEE;}
#nav li a:hover{background:#F1E9DC;}
#nav li ul
{
line-height: 27px; list-style-type: none;text-align:left;
left: -999em; width: 100px; position: absolute;
}
#nav li ul li{
float: left; width: 100px;
background:#F1E9DC
}
#nav li ul a{
display: block; width: 100px;w\idth: 100px;text-align:left;padding-left:24px;
}
#nav li ul a:link {text-decoration:none;}
#nav li ul a:visited {text-decoration:none;}
#nav li ul a:hover {text-decoration:none;font-weight:normal;}
#nav li:hover ul { left: auto;}
#nav li.sfhover ul {left: auto;}
#content {clear: left;}
-->
</style>
<script type="text/javascript">
function menuFix() {
var sfEls = document.getElementById("nav").getElementsByTagName("li");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=(this.className.length>0? " ": "") + "sfhover";
}
sfEls[i].onMouseDown=function() {
this.className+=(this.className.length>0? " ": "") + "sfhover";
}
sfEls[i].onMouseUp=function() {
this.className+=(this.className.length>0? " ": "") + "sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),
"");
}
}
}
window.onload=menuFix;
//--><!]]>
</script>
</head>
<body>
<ul id="nav">
<li runat="server" ID="Li1">
<a href="#"><img src="images/f.jpg" width="100" height="41"></a>
</li>
<li runat="server" ID="Li2">
<a href="#"><img src="images/e.jpg" width="100" height="41"></a>
</li>
<li runat="server" ID="Li3">
<a href="#"><img src="images/d.jpg" width="97" height="41"></a>
<ul>
<li runat="server" ID="Li4">
<a href="a.aspx?type='D1'">产品1</a></li>
</ul>
</li>
<li runat="server" ID="Li5">
<a href="#"><img src="images/c.jpg" width="97" height="41"></a>
<ul>
<li runat="server" ID="Li6">
<a href="a.aspx?type='C1'">产品1</a></li>
<li runat="server" ID="Li7">
<a href="a.aspx?type='C1'">产品1</a></li>
<li runat="server" ID="Li8">
<a href="a.aspx?type='C1'">产品1</a></li>
<li runat="server" ID="Li9">
<a href="a.aspx?type='C1'">产品1</a></li>
</ul>
</li>
</ul>
</body>
</html>
后台a.aspx.cs代码文件:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if( !this.IsPostBack)
{
if (this.ddlb_type.SelectedValue.ToString().Replace("'", "''").Trim() != "G")
{
this.HyperLink1.Text=this.ddlb_type.SelectedItem.Text.ToString().Trim();
}
}
}
但是运行的时候系统提示如下错误:
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 137: if (Request["type"].ToString() == null || Request["type"].ToString() == "")
请问该如何解决以上问题,谢谢,在线等.