你是想在哪里读出???客户端还是服务器端?kind regard!!!!

解决方案 »

  1.   

    Label1.Text=TextBox1.Style["LEFT"].ToString();
    可以的。
      

  2.   

    Label1.Text=TextBox1.Style["LEFT"].ToString();
    可以的。
      

  3.   

    本来就可以读出来,但必需先赋值才能读出来!!!!
    如Left属性,将控件拖到窗体后,如果不在运行期设置
    将读出来空值.我测试的代码很简单,请各位指点:[设计代码]
    <%@ Page language="c#" Codebehind="position.aspx.cs" AutoEventWireup="false" Inherits="HRdotnet.position" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>position</title>
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="position" method="post" runat="server">
    <asp:TextBox id="txt" style="Z-INDEX: 101; LEFT: 141px; POSITION: absolute; TOP: 63px" runat="server"></asp:TextBox>
    <asp:Calendar id="cal" style="Z-INDEX: 102; LEFT: 140px; POSITION: absolute; TOP: 90px" runat="server" BorderWidth="1px" NextPrevFormat="FullMonth" BackColor="White" Width="224px" ForeColor="Black" Height="147px" Font-Size="9pt" Font-Names="Verdana" BorderColor="White">
    <TodayDayStyle BackColor="#CCCCCC"></TodayDayStyle>
    <NextPrevStyle Font-Size="8pt" Font-Bold="True" ForeColor="#333333" VerticalAlign="Bottom"></NextPrevStyle>
    <DayHeaderStyle Font-Size="8pt" Font-Bold="True"></DayHeaderStyle>
    <SelectedDayStyle ForeColor="White" BackColor="#333399"></SelectedDayStyle>
    <TitleStyle Font-Size="12pt" Font-Bold="True" BorderWidth="4px" ForeColor="#333399" BorderColor="Black" BackColor="White"></TitleStyle>
    <OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
    </asp:Calendar>
    <asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 317px; POSITION: absolute; TOP: 63px" runat="server" Text="btn"></asp:Button>
    <asp:Button id="Button2" style="Z-INDEX: 104; LEFT: 42px; POSITION: absolute; TOP: 108px" runat="server" Text="Button"></asp:Button></form>
    </body>
    </HTML>[codebehind代码]using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace HRdotnet
    {
    /// <summary>
    /// position 的摘要说明。
    /// </summary>
    public class position : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox txt;
    protected System.Web.UI.WebControls.Calendar cal;
    protected System.Web.UI.WebControls.Button Button2;
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Button2.Click += new System.EventHandler(this.Button2_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion public string GetTextRect(TextBox txt)
    {
    return "Left:"+txt.Style["Left"]+"px;Top:"+txt.Style["Top"]+"px;Width:"+txt.Style["Width"]+"px;Height:"+txt.Style["Height"]+"px";

    } private void Button1_Click(object sender, System.EventArgs e)
    {
    Response.Write(this.GetTextRect(this.txt));
    Response.Write(this.GetCalRect(this.cal));
    } public string GetCalRect(Calendar cal)
    {
    return "Left:"+cal.Style["Left"]+"px;Top:"+cal.Style["Top"]+"px;Width:"+cal.Style["Width"]+"px;Height:"+cal.Style["Height"]+"px";
    } private void Button2_Click(object sender, System.EventArgs e)
    {
    cal.Style.Add("Left","100");
    }
    }
    }
      

  4.   

    其实我要实现的东西很简单,就是想在一个按钮事件中取得另一个文本框的LEFT之类的属性,然后将一个calendar移动到文本框的下方.大家可以先试试看我的代码.
      

  5.   

    默认值就是"left"啊,如果为空你就把它当成left不就行了