Page_Load:
if (Request["Textbox1"]!null)
    TextBox1.Attribues["value"]=Request["TextBox1"].Tostring()

解决方案 »

  1.   

    楼上大侠:
    c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx.cs(213): “System.Web.UI.WebControls.TextBox”并不包含对“Attribues”的定义
      

  2.   

    不会不包含Attributes吧你也可以这样啊TextBox1.text="...";
      

  3.   

    this.DepartmentID.Attributes.Add("value","123456");
      

  4.   

    http://expert.csdn.net/Expert/TopicView1.asp?id=2561040
    使用里面的SafePwdBox
      

  5.   

    楼上很历害,可是我刚用ASP.NET,还不想使用第三方控件:)
      

  6.   

    Attribues敲错了,是Attributes
    如loulanlouzhu(桃花潭水深千尺,不及阿勇念你情) 所说
      

  7.   

    这是原代码namespace Lostinet.Web
    {
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel; /// <summary>
    /// SafePwdBox is input box that value not be clear when postback
    /// </summary>
    [DefaultEvent("ValueChanged")]
    [DefaultProperty("Value")]
    [ValidationProperty("Value")]
    public class SafePwdBox : WebControl , IPostBackDataHandler
    {
    /// <summary>
    /// char for mask at client
    /// </summary>
    static public char MaskChar
    {
    get
    {
    return '~';
    }
    } /// <summary>
    /// .ctor
    /// </summary>
    public SafePwdBox():base(HtmlTextWriterTag.Input)
    {
    } /// <summary>
    /// get the key for Cache
    /// </summary>
    protected string GetCacheKey()
    {
    string key=(string)ViewState["ck"];
    if(key==null)
    {
    key=Guid.NewGuid().GetHashCode().ToString("x");
    ViewState["ck"]=key;
    ViewState.SetItemDirty("ck",true);
    }
    return key;
    } /// <summary>
    /// CacheTimeout
    /// </summary>
    [DefaultValue(30)]
    public int CacheTimeout
    {
    get
    {
    return ct;
    }
    set
    {
    ct=value;
    }
    }
    int ct=30; /// <summary>
    /// is in design
    /// </summary>
    protected bool DesignMode
    {
    get
    {
    return (Site!=null&&Site.DesignMode)||Context==null||HttpContext.Current==null;
    }
    } /// <summary>
    /// password
    /// </summary>
    [DefaultValue("")]
    [Bindable(true)]
    public string Value
    {
    get
    {
    if(DesignMode)
    {
    string v=(string)ViewState["v"];
    return v==null?"":v;
    }
    else
    {
    string v=(string)Context.Cache[GetCacheKey()];
    return v==null?"":v;
    }
    }
    set
    {
    if(DesignMode)
    {
    ViewState["v"]=value;
    }
    else
    {
    Context.Cache.Insert(GetCacheKey(),value,null,DateTime.MaxValue,TimeSpan.FromMinutes(CacheTimeout),System.Web.Caching.CacheItemPriority.NotRemovable,null);
    }
    }
    } static object EventValueChanged=new object(); /// <summary>
    /// fired when value changed
    /// </summary>
    public event EventHandler ValueChanged
    {
    add
    {
    Events.AddHandler(EventValueChanged,value);
    }
    remove
    {
    Events.RemoveHandler(EventValueChanged,value);
    }
    } /// <summary>
    /// fire ValueChanged
    /// </summary>
    protected virtual void OnValueChanged(EventArgs e)
    {
    EventHandler handler=(EventHandler)Events[EventValueChanged];
    if(handler!=null)
    handler(this,e);
    } /// <summary>
    /// override to render attributes
    /// </summary>
    protected override void AddAttributesToRender(HtmlTextWriter writer)
    {
    writer.AddAttribute(HtmlTextWriterAttribute.Name,UniqueID);
    writer.AddAttribute(HtmlTextWriterAttribute.Type,"password",false);
    writer.AddAttribute(HtmlTextWriterAttribute.Value,new string(MaskChar,Value.Length),false);
    base.AddAttributesToRender(writer);
    }
    void IPostBackDataHandler.RaisePostDataChangedEvent()
    {
    OnValueChanged(EventArgs.Empty);
    } bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
    {
    char mc=MaskChar;
    string v=Value;
    char[] nvs=postCollection[postDataKey].ToCharArray();
    for(int i=0;i<v.Length&&i<nvs.Length;i++)
    {
    if(nvs[i]==mc)
    nvs[i]=v[i];
    }
    string nv=new string(nvs);
    if(v!=nv)
    {
    Value=nv;
    return true;
    }
    return false;
    }
    }
    }
      

  8.   

    to loulanlouzhu(桃花潭水深千尺,不及阿勇念你情) c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx.cs(213): “System.Web.UI.WebControls.TextBox”并不包含对“DepartmentID”的定义
      

  9.   

    to loulanlouzhu(桃花潭水深千尺,不及阿勇念你情) c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx.cs(213): “System.Web.UI.WebControls.TextBox”并不包含对“DepartmentID”的定义
    ---》》晕!!!!!!
      DepartmentID是你的密码文本框的ID,改 下就好了!