当前位置: 代码迷 >> ASP.NET >> 在cs代码中定义的变量如何在页面代码中使用
  详细解决方案

在cs代码中定义的变量如何在页面代码中使用

热度:2289   发布时间:2013-02-25 00:00:00.0
在cs代码中定义的变量怎么在页面代码中使用
例如
cs代码中定义了
public   string   strPageType   =   "供应信息 ";

但在页面中使用
<title> <%#   strPageType   %> </title>
发现是空的字符串
但没有说不存在
就是说找到strPageType但没取到值

该怎么做呢

------解决方案--------------------------------------------------------
拖控件然后在CS里写代码用吧。我不喜欢在页面中绑定值。
.cs
public string strPageType = "供应信息 ";
Label1.Text= strPageType ;

------解决方案--------------------------------------------------------
<title> <%=strPageType %> </title>

------解决方案--------------------------------------------------------
<title> <%=strPageType%> </title>
------解决方案--------------------------------------------------------
Response.Write()
说白了就是输出
------解决方案--------------------------------------------------------
.net1.1:
<title id= "t1 " runat = server> </title>
page_load中写:
t1.Text = " ";//(好像是Text)

.net2.0:
直接this.Title = " ";
  相关解决方案