I'm trying to convert code from a WinForm to a WinApp, but I know very little of aspx, and nothing of javascript.
I have programmatically created a textbox that will be given text. The text is then passed through a validation method like so:
text.Validating += new CancelEventHandler(boolean_Validating);
goes to
private void boolean_Validating(object sender, CancelEventArgs e)
{
TextBox textBox = (TextBox)sender;
string boolean = textBox.Text;
string message = null;
if (!checkBooleanSyntax(boolean, out message))
{
Response.Write("Error: " + message);
e.Cancel = true;
textBox.Text = message;
}
}
ASPX doesn't have a definition for the text.Validating part. How else can I validate the text using a Cancel Event Handler?
In asp.net we use validation controls. Those can take care of the job on client side (if user hasn't disable javascript in his browser) and then on the server side (so you can be sure that user won't just disable js and can immediately freely exploit your app).
If you need some special validation with specific logic, you can write yourself a custom validator control.
Can't write everything here, because this topic can be covered by multiple chapters in a book, but look here for more information: http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp
http://msdn.microsoft.com/en-us/library/aa479013.aspx