你说的 “Font又回到了以前状态”是什么意思啊?不懂,请详细说明

解决方案 »

  1.   

    web:
    接下来是有关用户控件属性的问题:
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %><script language="C#" runat="server">
      string ConnStr;  public string ConnectionString
      {
       get {return ConnStr;}
       set {ConnStr = value;}
      }
     //这里定义了属性ConnectionString ,具体用法见后面  public void Page_Load(Object Source, EventArgs E)
      {
        if (!IsPostBack)
        {
          SqlConnection myConnection;
          SqlCommand myCommand;
          SqlDataReader myReader;
          string SQL;      SQL = "select * from Shippers";
          if (ConnStr == "")//设置默认连接字符串
           ConnStr = ConfigurationSettings.AppSettings["DsnNorthwind"];      myConnection = new SqlConnection(ConnStr);
          myConnection.Open();      myCommand = new SqlCommand(SQL, myConnection);      myReader = myCommand.ExecuteReader();      while (myReader.Read())
            ShipMethod.Items.Add(new ListItem(myReader["CompanyName"].ToString(), myReader["ShipperID"].ToString()));
          
        }
      }
    </script><asp:DropDownList id="ShipMethod" runat="server"/> 在aspx文件中用法:
    <%@ Page Language="C#" %><%@ Register tagprefix="wrox" Tagname="shipment" Src="shipmethod_prop.ascx" %><html>
    <head>
     <title>Testing our User Control - Part 2</title>
    </head><script runat="server">  void Page_Load(Object sender, EventArgs e)
      {
       ShipMethod.ConnectionString = ConfigurationSettings.AppSettings["DsnNorthwind"];
      }//注意这儿
      
    </script><body>
    <form runat="server">
    <strong>Here is some body text.</strong><P>Please choose a shipping method: 
    <wrox:shipment id="ShipMethod" runat="server" /></P></form>
    </body>
    </html>
    还有种方法:
    <wrox:shipment ConnectionString="server=localhost;uid=sa;pwd=;database=Northwind" runat="server" />
    即:把ConnectionString和值放入wrox:shipment用户控件中作为属性
      

  2.   

    意思是我在设计状态下可以把字体设成小二,但一运行程序,字体又变成了9号,也就是说font属性不能保存
      

  3.   

    你font属性是定义在用户控件中的??