在test.aspx中有这样一个checkbox
<form name="form1" method="post" action="Default.aspx">
<input type="checkbox" name="check_id" size="6" value="1" >
<input type="submit" name="ok" value="确定">
</form>然后在Default.aspx.cs中写了这么一个函数
public string test()
{
string i = Request.Form["check_id"].ToString();
if (i==""||i==null)
{
return "aaa";
}
return i;
}
我的意思是如果这个checkbox选中了,显示value的值,未选中就显示空。可是当我不选中的话,按下按钮,错误信息如下:
System.NullReferenceException: Object reference not set to an instance of an object.
为什么不行呢??有办法解决吗,大家帮忙啊!!!!!!!!!
<form name="form1" method="post" action="Default.aspx">
<input type="checkbox" name="check_id" size="6" value="1" >
<input type="submit" name="ok" value="确定">
</form>然后在Default.aspx.cs中写了这么一个函数
public string test()
{
string i = Request.Form["check_id"].ToString();
if (i==""||i==null)
{
return "aaa";
}
return i;
}
我的意思是如果这个checkbox选中了,显示value的值,未选中就显示空。可是当我不选中的话,按下按钮,错误信息如下:
System.NullReferenceException: Object reference not set to an instance of an object.
为什么不行呢??有办法解决吗,大家帮忙啊!!!!!!!!!
解决方案 »
- 如何单击网页上一个按钮,运行一个desktop 程序, 比如notepad
- inline inline-block block 没有inline-block就天下太平了,inline-block的存在价值是什么啊
- GirdView绑定如何让字段 左右顺序调整
- .net平台与EXTJS数据交互问题
- 关于DataGrid嵌套repeater的问题急!!!!
- Calendar控件问题
- 关于复合条件查询大家有没有好方法或思路?
- 这个存储过程怎么写?
- 如何地址栏传值的加密。
- 关于图像缩放的显示????
- 请问如何在服务器端生成一个EXCEL文件,然后在这个EXCEL的一些格中填写一些数据,然后给用户下载?
- window.event没有属性?
就这样啊,如果我选中的话是可以显示的,但是不选就报错,为什么啊?
public string test()
{
string i = Request.Form["check_id"];
if (i==""||i==null)
{
return "aaa";
}
return i;
}