我用的c#跟着书上做的遇到一些问题请高手指点,代买如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script runat ="server" >
void Page_Load(Object sender, EventArgs e)
{
int numrouws = Convert.ToInt32(select1.value);
int numcells = Convert.ToInt32(select2.value);
//循环
for (int j = 0; j < numrouws; j++)
{
HtmlTableRow row = new HtmlTableRow();
if (j % 2 == 1)
row.BgColor = "Gray";
for (int i = 0; i < numcells; i++)
{
HtmlTableCell cell = new HtmlTableCell();
cell.Controls.Add(new LiteralControl("row" + j.ToString ()+ "行,第" + i.ToString() + "列"));
row.Cells.Add(cell);
}
Table1.Rows.Add(row);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table id ="Table1" cellpadding ="5" cellspacing ="0" border ="1" runat ="server" />
<hr/>
选择行数:
<select id="select1" runat ="server" >
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
选择列数:
<select id="select2" runat ="server" >
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
<br/><br/>
<input type="submit" value="生成表格" runat ="server" />
</form>
</body>
</html>
遇到的错误是 1、int numrouws = Convert.ToInt32(select1.value);
int numcells = Convert.ToInt32(select2.value);
这2句语句提示是不存在value方法2、警告 1 “ASP.default_aspx.Page_Load(object, System.EventArgs)”隐藏了继承的成员“_Default.Page_Load(object, System.EventArgs)”。如果是有意隐藏,请使用关键字 ne 这句我不懂是什么意思3 在<table id ="Table1" cellpadding ="5" cellspacing ="0" border ="1" runat ="server" />这个标签中本来有个属性是bordcolor的但是程序调试的时候说不存在这个属性!我用的vs20084、<option>这个标签有点时候会说不允许在<form>或者<body>中使用求高手解答!
分不多谢了!
------解决方案--------------------------------------------------------
父类有同名的方法,有没有virtual,用new覆盖父类的方法