I want to create a button 'numeric only' in visual webgui (and i dont want to use masked textbox).
I did that: http://msdn.microsoft.com/en-us/library/ms229644(v=vs.80).aspx This solution works in WinForms but doesn't work in WebGui. I have to delivered from Gizmox control TextBox of course.
So.. I have tried to create a textbox, with sets property Text="OK"
, every time focus is lost.
Like that:
using Gizmox.WebGUI.Forms;
namespace MyControls
{
public partial class NumTextBox : TextBox
{
public NumTextBox()
{
InitializeComponent();
}
protected override void OnLostFocus(EventArgs e)
{
this.Text = "OK";
}
}
}
Why it doesn't work? Please help,
try this
public partial class NumTextBox : TextBox
{
public NumTextBox()
{
LostFocus += new EventHandler(NumTextBox_LostFocus);
}
private void NumTextBox_LostFocus(object sender, EventArgs e)
{
this.Text = "OK";
}
}
But note that vwg is a strange place. All your c# code is executed server side so such numeric text box might generate some unwanted traffic. Maybe you will be better of with this:
new TextBox { Validator = TextBoxValidation.IntegerValidator };
which will suppress not numeric characters from being added to textbox.