Help with Customized TextBox control.


S

Sanjay Pais

Hi,

I have successfully added my TextBox control that inherits from the
TextBox. I have added a property called ApplySecurity that can be changed in
the designer and is reflected in the source HTML.

I want to add the TextBox icon in the toolbox and want the value to toggle
in the property window in design mode. The values allowed are True & False.
How can I achieve this?

We are using VS 2005 Beta 2

Cheers

Sanjay
Source Code:

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.ComponentModel;

using System.Drawing;

using System.Diagnostics;

using System.Design;



[ToolboxData("<{0}:ATextBox runat=server
ApplySecurity=False></{0}:ATextBox>")]

public class ATextBox : System.Web.UI.WebControls.TextBox

{

[Bindable(true),

Description("A custom AE Textbox"),

Category("Misc"),

DefaultValue("False")]

private string strApplySecurity = "False";

public string ApplySecurity

{


get

{

return strApplySecurity;

}

set

{

strApplySecurity = value;

}



}

protected override void Render(HtmlTextWriter w)

{

w.AddAttribute("ApplySecurity", strApplySecurity);

base.Render(w); }

}
 
Ad

Advertisements

Ad

Advertisements

S

Sanjay Pais

Thanks for the reply. I actually did finally implement the TrueFalse value
as a bool flag and was able to get the toggle in the properties window.

I want to use the icons from the system equivalent so for example, if i am
creating a custom control that inherits from the TextBox, how can I use the
icon for the textbox in my toolbox?

Thanks in advance

Sanjay
Teemu Keiski said:
Hi,

What if the type of the ApplySecurity property would be bool and you'd
handle the translation to string in the AddAttribute method? bool type
would automatically get True | False selection to property browser (if
that's what you mean).

What comes to the icon, check ToolboxBitmapAttribute
http://msdn2.microsoft.com/library/4wk1wc0a(en-us,vs.80).aspx


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


Sanjay Pais said:
Hi,

I have successfully added my TextBox control that inherits from the
TextBox. I have added a property called ApplySecurity that can be changed
in the designer and is reflected in the source HTML.

I want to add the TextBox icon in the toolbox and want the value to
toggle in the property window in design mode. The values allowed are True
& False. How can I achieve this?

We are using VS 2005 Beta 2

Cheers

Sanjay
Source Code:

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.ComponentModel;

using System.Drawing;

using System.Diagnostics;

using System.Design;



[ToolboxData("<{0}:ATextBox runat=server
ApplySecurity=False></{0}:ATextBox>")]

public class ATextBox : System.Web.UI.WebControls.TextBox

{

[Bindable(true),

Description("A custom AE Textbox"),

Category("Misc"),

DefaultValue("False")]

private string strApplySecurity = "False";

public string ApplySecurity

{


get

{

return strApplySecurity;

}

set

{

strApplySecurity = value;

}



}

protected override void Render(HtmlTextWriter w)

{

w.AddAttribute("ApplySecurity", strApplySecurity);

base.Render(w); }

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top