asp.net 如何将string型转换为Label型并且可以设置服务器控件属性 看看能不能通过lable得 autopostback属性来处理 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px";把这个名称改一下别用Html的关键字试试 没有看到从注册表取值的代码。 "left: 341px; position: absolute;top:193px";如果是注册表里的就是把341px和193px那里改成动态,显示从注册表里读出来的值即可我直接用静态的代替了,效果一样,不影响问题-------------------------------------------------------------writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px"; 把这个名称改一下别用Html的关键字试试改过,top,left之类,都没用--------------------------------------------------------------要不你看一下生成的代码(就是套页面后的)的标点符号是否有错writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px";上边这句不行,而下边这句就行,writeKey_Label的值为“lblDSRText”lblDSRText.Style["Style"] = "left: 341px; position: absolute;top:193px";-----------------------------------------------------------------谁知道做我加100分! string writeKey = "lblDSRText";Label writeKey_Label = new Label();writeKey_Label.ID = writeKey;writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px";this.Controls.Add(writeKey_Label);试试 Label l = (Label)this.FindControl("lblDSRText"); if (l != null) { l.Style["color"] = "red"; } Label writeKey_Label = this.FindControl("lblDSRText") as Label;if(writeKey_Label != null){ writeKey_Label.Style["left"] = "341px"; writeKey_Label.Style["position"] = "absolute"; writeKey_Label.Style["top"] = "193px";} Response.Write(writeKey_Label.Style["Style"]);??? 看来应该改改,服务器控件应该是在form里的:Label writeKey_Label = this.form1.FindControl("lblDSRText") as Label;//查找form1中的ID为lblDSRText的Labelif(writeKey_Label!=null){ writeKey_Label.Style["left"]="341px"; writeKey_Label.Style["position"]="absolute"; writeKey_Label.Style["top"]="193px";} string writeKey = "lblDSRText";Label writeKey_Label = (Label)Page.FindControl(writeKey); // new Label(); //writeKey_Label.ID = writeKey; // 大哥啊,你以为,给了一样的ID就是同一个 Label ?writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px";Response.Write(writeKey_Label.Style["Style"]); this.form1.FindControl("lblDSRText") as Label;这样找不到form1this.FindControl("lblDSRText") as Label;这样值为null我这个页面是继承的母版页,应该是母版页的的问题吧?<%@ Page Language="C#" MasterPageFile="~/public/MenuIndexContainerHeader.master" AutoEventWireup="true" CodeFile="CFJDS.aspx.cs" Inherits="private_dzjc_DYSZ_CFJDS" Title="Untitled Page" %> 你首先应该明确这个Label在什么地方,也就是它的上级控件是什么?如果你不知道什么是它的上级控件,就看看它被包含在哪个runat="server"的控件里 asp.net C#怎么获取excel的实际列数 一个页面两个datalist无法进行分页 Windows域中身份验证的问题 再问菜单控件???(弱弱的问题) ds.Tables["table1"].Column["title"]这个在后台如何取值?? 关于水晶报表中参数的问题 急,简单问题,将两名VB.NET转成C#. 关于vs的版本问题 怎样做出象超市小票那样的打印程序? DataGrid模板问题!急! 急 在线等待 求关于asp.nat二级级联下拉菜单的做法
"left: 341px; position: absolute;top:193px";如果是注册表里的就是把341px和193px那里改成动态,显示从注册表里读出来的值即可
我直接用静态的代替了,效果一样,不影响问题-------------------------------------------------------------
writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px"; 把这个名称改一下别用Html的关键字试试改过,top,left之类,都没用
--------------------------------------------------------------
要不你看一下生成的代码(就是套页面后的)的标点符号是否有错writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px";上边这句不行,而下边这句就行,writeKey_Label的值为“lblDSRText”lblDSRText.Style["Style"] = "left: 341px; position: absolute;top:193px";
-----------------------------------------------------------------谁知道做我加100分!
试试
if (l != null)
{
l.Style["color"] = "red";
}
Label writeKey_Label = this.FindControl("lblDSRText") as Label;
if(writeKey_Label != null)
{
writeKey_Label.Style["left"] = "341px";
writeKey_Label.Style["position"] = "absolute";
writeKey_Label.Style["top"] = "193px";
}
if(writeKey_Label!=null)
{
writeKey_Label.Style["left"]="341px";
writeKey_Label.Style["position"]="absolute";
writeKey_Label.Style["top"]="193px";
}
Label writeKey_Label = (Label)Page.FindControl(writeKey); // new Label(); //writeKey_Label.ID = writeKey; // 大哥啊,你以为,给了一样的ID就是同一个 Label ?writeKey_Label.Style["Style"] = "left: 341px; position: absolute;top:193px";Response.Write(writeKey_Label.Style["Style"]);
这样找不到form1this.FindControl("lblDSRText") as Label;
这样值为null
我这个页面是继承的母版页,应该是母版页的的问题吧?<%@ Page Language="C#" MasterPageFile="~/public/MenuIndexContainerHeader.master" AutoEventWireup="true" CodeFile="CFJDS.aspx.cs" Inherits="private_dzjc_DYSZ_CFJDS" Title="Untitled Page" %>
如果你不知道什么是它的上级控件,就看看它被包含在哪个runat="server"的控件里