急。树型目录问题 我在.cs中写了一个实现树型目录showTree()。将生成的html代码赋给了一个变量strTree怎样才能在.aspx页面中显示该目录。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看不懂什么意思.Lable1.Text = strTree ; ? 变量定义为 public 访问级别aspx中写在页面里写 <%=变量名%>或者在页面里放一个label控件cs 中写label1.Text = 变量名; label1.Text = 变量名;我试过,好象不能显示图片吧<%=变量名%>也是一片空白 public string strTree;......<%=strTree%> private string ShowTree() { string ConnSql1=""; string ConnSql2=""; string ConnSql3=""; string ConnSql4=""; ConnSql1="select departmentid,departmentName from Departments where ParentID='' order by departmentid"; DataSet RsCatalog1=new DataSet (); RsCatalog1=Dbc.getBinding (ConnSql1,"s"); strTree="<div style='cursor:hand'>"; if (RsCatalog1.Tables[0].Rows.Count>0) { for (int i=1;i<=RsCatalog1.Tables[0].Rows.Count;i++) { ConnSql2="select departmentid,departmentName from Departments where ParentID='"+RsCatalog1.Tables[0].Rows [i]["departmentid"] +"' order by departmentid"; DataSet RsCatalog2=new DataSet (); RsCatalog2=Dbc.getBinding (ConnSql2,"s"); if (RsCatalog2.Tables[0].Rows.Count>0) { strTree=strTree+"<span height=40 ID='Grades"+i+"' CLASS='Outline' title='"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"'> <IMG SRC='../images/folder.gif' border=0 ID='Grades"+i+"dd' WIDTH='16' HEIGHT='16'>"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"<br></span>"; strTree=strTree+"<DIV ID=Grades"+i+"d STYLE='display:none' CLASS='hide'>"; for (int j=1;j<=RsCatalog2.Tables[0].Rows.Count;j++) { ConnSql3="select departmentid,departmentName from Departments where ParentID='"+RsCatalog2.Tables[0].Rows [j]["departmentid"] +"' order by departmentid"; DataSet RsCatalog3=new DataSet (); RsCatalog3=Dbc.getBinding (ConnSql3,"s"); if (RsCatalog3.Tables[0].Rows.Count>0) { strTree=strTree+" <span height=40 ID='Gradesj"+i+j+"' CLASS='Outline' title='"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"'> <IMG SRC='../images/folder.gif'ID='Gradesj"+i+j+"dd' WIDTH='16' HEIGHT='16'>"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"</span><br>"; strTree=strTree+"<DIV ID=Gradesj"+i+j+"d STYLE='display:none' CLASS='hide'>"; for (int k=1;k<=RsCatalog3.Tables[0].Rows.Count;k++) { ConnSql4="select departmentid,departmentName from Departments where ParentID='"+RsCatalog3.Tables[0].Rows [k]["departmentid"] +"' order by departmentid"; DataSet RsCatalog4=new DataSet (); RsCatalog4=Dbc.getBinding (ConnSql4,"s"); if (RsCatalog4.Tables[0].Rows.Count>0) { strTree=strTree+" <span height=40 ID='Gradesk"+i+j+k+"' CLASS='Outline' title='"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"'> <IMG SRC='../images/folder.gif' ID='Gradesk"+i+j+k+"dd' WIDTH='16' HEIGHT='16'>"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"</span><br>"; strTree=strTree+"<DIV ID=Gradesk"+i+j+k+"d STYLE='display:none' CLASS='hide'>"; for (int l=1;l<=RsCatalog4.Tables[0].Rows.Count;l++) { strTree=strTree+" <span height=40><IMG SRC='../images/htmlicon.gif' WIDTH='10' HEIGHT='10'> <a href=../sec_page/show.asp?subID="+RsCatalog4.Tables[0].Rows [l]["departmentid"]+" target=rightframe title='"+RsCatalog4.Tables[0].Rows [l]["departmentName"]+"'>"+RsCatalog4.Tables[0].Rows [l]["departmentName"]+"</a></span><br>"; strTree=strTree+"</div>"; } } else { strTree=strTree+" <span height=40> <IMG SRC='../images/htmlicon.gif' WIDTH='10' HEIGHT='10'> <a href=../sec_page/show.asp?subID="+RsCatalog3.Tables[0].Rows [k]["departmentid"]+" target=rightframe title='"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"'>"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"</a></span><br>"; } //RsCatalog4.close:Set RsCatalog4=Nothing } strTree=strTree+"</div>"; } else { strTree=strTree+" <span height=40><IMG SRC='../images/htmlicon.gif' WIDTH='10' HEIGHT='10'> <a href=../sec_page/show.asp?subID="+RsCatalog2.Tables[0].Rows [j]["departmentid"]+" target=rightframe title='"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"'>"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"</a></span><br>"; } //RsCatalog3.Close:Set RsCatalog3=Nothing } strTree=strTree+"</div>"; } else { strTree=strTree+" <span height=40><IMG SRC='../images/htmlicon.gif' ID='Grades"+i+"' WIDTH='10' HEIGHT='10'>"+" <a href=../sec_page/show.asp?subID="+RsCatalog1.Tables[0].Rows [i]["departmentid"]+" target=rightframe title='"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"'>"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"</a></span><br>"; } //RsCatalog2.Close:Set RsCatalog2=Nothing } } else { strTree=strTree+"<font color=red><b></b></font>"; } strTree=strTree+"</div>"; //RsCatalog1.Close:Set RsCatalog1=Nothing //this.LoadTemplate =strTree; return strTree; } 大家帮我看一下,上面代码中的返回值strTree,怎样才能在.aspx中实现出来 我用的是vb.net 你试试Page_Load 里加response.write(strTree) 也不行啊,我本来是直接用response.write写的,后来才改成用变量存放 一句话解决兼容性难题! 关于FORM验证的使用 如何获取ldap 地址 visual studio如何发布aspx.net网站啊? textbox和label 数据关联问题.. 高手请看过来,关于基本的owc问题! WEB中关与DATAGRID 问题 UpdatePanel控件与Repeater中子控件使用问题 访问安全性问题 我的www服务不断的意外终止,怎么回事?我会疯掉了! 如何用js动态创建一个热点(Hotspot)? BS模式下如何实现类似条形码扫描的功能
Lable1.Text = strTree ; ?
aspx中写
在页面里写 <%=变量名%>或者在页面里放一个label控件
cs 中写
label1.Text = 变量名;
我试过,好象不能显示图片吧<%=变量名%>也是一片空白
...
...
<%=strTree%>
{
string ConnSql1="";
string ConnSql2="";
string ConnSql3="";
string ConnSql4="";
ConnSql1="select departmentid,departmentName from Departments where ParentID='' order by departmentid";
DataSet RsCatalog1=new DataSet ();
RsCatalog1=Dbc.getBinding (ConnSql1,"s"); strTree="<div style='cursor:hand'>";
if (RsCatalog1.Tables[0].Rows.Count>0)
{
for (int i=1;i<=RsCatalog1.Tables[0].Rows.Count;i++)
{
ConnSql2="select departmentid,departmentName from Departments where ParentID='"+RsCatalog1.Tables[0].Rows [i]["departmentid"] +"' order by departmentid";
DataSet RsCatalog2=new DataSet ();
RsCatalog2=Dbc.getBinding (ConnSql2,"s");
if (RsCatalog2.Tables[0].Rows.Count>0)
{
strTree=strTree+"<span height=40 ID='Grades"+i+"' CLASS='Outline' title='"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"'> <IMG SRC='../images/folder.gif' border=0 ID='Grades"+i+"dd' WIDTH='16' HEIGHT='16'>"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"<br></span>";
strTree=strTree+"<DIV ID=Grades"+i+"d STYLE='display:none' CLASS='hide'>";
for (int j=1;j<=RsCatalog2.Tables[0].Rows.Count;j++)
{
ConnSql3="select departmentid,departmentName from Departments where ParentID='"+RsCatalog2.Tables[0].Rows [j]["departmentid"] +"' order by departmentid";
DataSet RsCatalog3=new DataSet ();
RsCatalog3=Dbc.getBinding (ConnSql3,"s");
if (RsCatalog3.Tables[0].Rows.Count>0)
{
strTree=strTree+" <span height=40 ID='Gradesj"+i+j+"' CLASS='Outline' title='"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"'> <IMG SRC='../images/folder.gif'ID='Gradesj"+i+j+"dd' WIDTH='16' HEIGHT='16'>"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"</span><br>";
strTree=strTree+"<DIV ID=Gradesj"+i+j+"d STYLE='display:none' CLASS='hide'>";
for (int k=1;k<=RsCatalog3.Tables[0].Rows.Count;k++)
{
ConnSql4="select departmentid,departmentName from Departments where ParentID='"+RsCatalog3.Tables[0].Rows [k]["departmentid"] +"' order by departmentid";
DataSet RsCatalog4=new DataSet ();
RsCatalog4=Dbc.getBinding (ConnSql4,"s");
if (RsCatalog4.Tables[0].Rows.Count>0)
{
strTree=strTree+" <span height=40 ID='Gradesk"+i+j+k+"' CLASS='Outline' title='"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"'> <IMG SRC='../images/folder.gif' ID='Gradesk"+i+j+k+"dd' WIDTH='16' HEIGHT='16'>"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"</span><br>";
strTree=strTree+"<DIV ID=Gradesk"+i+j+k+"d STYLE='display:none' CLASS='hide'>";
for (int l=1;l<=RsCatalog4.Tables[0].Rows.Count;l++)
{
strTree=strTree+" <span height=40><IMG SRC='../images/htmlicon.gif' WIDTH='10' HEIGHT='10'> <a href=../sec_page/show.asp?subID="+RsCatalog4.Tables[0].Rows [l]["departmentid"]+" target=rightframe title='"+RsCatalog4.Tables[0].Rows [l]["departmentName"]+"'>"+RsCatalog4.Tables[0].Rows [l]["departmentName"]+"</a></span><br>";
strTree=strTree+"</div>";
}
}
else
{
strTree=strTree+" <span height=40> <IMG SRC='../images/htmlicon.gif' WIDTH='10' HEIGHT='10'> <a href=../sec_page/show.asp?subID="+RsCatalog3.Tables[0].Rows [k]["departmentid"]+" target=rightframe title='"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"'>"+RsCatalog3.Tables[0].Rows [k]["departmentName"]+"</a></span><br>";
} //RsCatalog4.close:Set RsCatalog4=Nothing
}
strTree=strTree+"</div>";
}
else
{
strTree=strTree+" <span height=40><IMG SRC='../images/htmlicon.gif' WIDTH='10' HEIGHT='10'> <a href=../sec_page/show.asp?subID="+RsCatalog2.Tables[0].Rows [j]["departmentid"]+" target=rightframe title='"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"'>"+RsCatalog2.Tables[0].Rows [j]["departmentName"]+"</a></span><br>";
} //RsCatalog3.Close:Set RsCatalog3=Nothing
}
strTree=strTree+"</div>";
}
else
{
strTree=strTree+" <span height=40><IMG SRC='../images/htmlicon.gif' ID='Grades"+i+"' WIDTH='10' HEIGHT='10'>"+" <a href=../sec_page/show.asp?subID="+RsCatalog1.Tables[0].Rows [i]["departmentid"]+" target=rightframe title='"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"'>"+RsCatalog1.Tables[0].Rows [i]["departmentName"]+"</a></span><br>";
} //RsCatalog2.Close:Set RsCatalog2=Nothing
}
}
else
{
strTree=strTree+"<font color=red><b></b></font>";
}
strTree=strTree+"</div>";
//RsCatalog1.Close:Set RsCatalog1=Nothing
//this.LoadTemplate =strTree;
return strTree;
}
Page_Load 里加
response.write(strTree)