Hey everyone
I made a litle custom textbox.
Something pretty easy to do but I encountered a problam which I cann't figure out how to do it.
on this moment I made this litle script
Offcourse the textbox works perfect but I have a problem in design mode.
When you add the textbox to your page you get this
now the problem I have is between the TextBox tags of the HTML in designmode
if you press < you can see you can add all kind of controls between the the tags but in my script I disabled all controls except text. I want to ask now how to disable any controls between the tags in designmode
I made a litle custom textbox.
Something pretty easy to do but I encountered a problam which I cann't figure out how to do it.
on this moment I made this litle script
Code:
[ParseChildren(false)]
[ValidationProperty("Text")]
[DefaultProperty("Text")]
[ToolboxData("<{0}:TextBox runat=\"server\"></{0}:TextBox>")]
[ToolboxBitmap(typeof(System.Web.UI.WebControls.TextBox))]
public class TextBox : WebControl, IPostBackDataHandler
{
public event EventHandler TextChanged;
protected virtual void OnTextChanged(EventArgs e)
{
if (TextChanged != null)
TextChanged(this, e);
}
public String Text
{
get { return (String)ViewState["Text"]; }
set { ViewState["Text"] = value; }
}
protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Input;
}
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
writer.AddAttribute(HtmlTextWriterAttribute.Value, Text);
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
//base.AddAttributesToRender(writer);
}
protected override void RenderContents(HtmlTextWriter writer)
{
//base.RenderContents(writer);
}
protected override void AddParsedSubObject(object obj)
{
if (obj is LiteralControl)
Text = ((LiteralControl)obj).Text;
else
throw new System.Web.HttpException("You cannot have a child control of type " + obj.GetType().Name.ToString());
}
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
string presentValue = Text;
string postedValue = postCollection[postDataKey];
if (presentValue == null || !presentValue.Equals(postedValue))
{
Text = postedValue;
return true;
}
return false;
}
public virtual void RaisePostDataChangedEvent()
{
OnTextChanged(EventArgs.Empty);
}
Offcourse the textbox works perfect but I have a problem in design mode.
When you add the textbox to your page you get this
HTML:
<custum:TextBox runat="server" ID="TextBox1">Test]</custom:Textbox>
now the problem I have is between the TextBox tags of the HTML in designmode
if you press < you can see you can add all kind of controls between the the tags but in my script I disabled all controls except text. I want to ask now how to disable any controls between the tags in designmode
Laatst bewerkt: