About Custom validator for name field [closed] - c#

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am Soft. Trainee.
I want to write a custom validator for Name field.
It should only include characters and space.
Please specify the code so that I can understand it well.
Kindly help.

Your question isn't very well defined so excuse me if I've taken it wrongly, but I'll have a go.
I would suggest a Regular expression validator (and maybe also add a Required Field Validator if the field is also required).
<asp:RegularExpressionValidator runat="server"
Text="Name isn't Valid"
ControlToValidate="nameTextBox"
ValidationExpression="^[0-9a-zA-Z ]+$"></asp:RegularExpressionValidator>
You may want to change the Expression to a more valid one for your situation, and obviously ensure the ControlToValidate points to the correct Textbox.

Related

How to define CheckBox in C# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have a check box in my form that I need to define along with other fields for inserting data. But I am not sure How to define it for inserting data. Below is my code.
cmd.Parameters.AddWithValue("#EmailTmp", (txtEmail.Text));
cmd.Parameters.AddWithValue("#PhoneTmp", (txtPhone.Text));
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.CheckBox));
Looking at your pasted code, I think you want this:
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.Checked));
or possibly something like:
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.Checked ? 1 : 0));
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.Checked));
This will give you a boolean value of true if checked, false if not. SQL will translate this into a 0/1 if you have the field in the SQL db as a bit.
Edit: As a side note, you don't need the "#" in front of the AgreeTmp

Regular expression to avoid null values [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I dont know how to use regex ,i have seen them to be used in email validation ,Is there any way i could restrict null values by using regular expression
/^(.+)$/
This regex will match anything which isn't empty (require one or more character), but is it really usefull to check it with a regex ?
The answer is no. null is not a value. It indicates you that the pointer doesn't point to anything. You can use "assert", or just if(yourobject==null){}

What are accelerators in C# and how do I use them? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
In my online course I'm asked to put a label (lblQuestion with accelerator) and ComboBox on a form.
Putting a label and a combo box on a form is simple enough in VS 2010, but I am not sure what an accelerator is and how I use it?
For setting an accelerator you will use & character in front of the letter of your label, that you need to make available as an accelerator. See here: http://blog.csharphelper.com/2012/05/30/use-accelerators-on-labels-and-buttons-in-c.aspx for more details.

Why "\n" is true doesn't compare? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Look at the sceene here , please:
http://social.microsoft.com/Forums/getfile/3600/
why it's not matching?
EDIT: Okay, now we know it's XmlReader.Value, which does return a string, that's definitely not the problem. I'll leave the previous answer below for future reference.
My guess is that there are some "odd" Unicode characters which don't show up in the debugger... or that the watch window is behaving strangely. Putting a watch on xml.Value.ToCharArray() would help to show that.
(As an aside, giving a Dictionary<,> parameter the name list is very confusing...)
EDIT: Additionally, using bracing and indentation would also make your code easier to follow...
We can't tell for sure at the moment, but my guess is that the Value property is of type object, not string. That means that == and != perform reference comparisons (operators are overloaded, not overridden, remember). You want the polymorphic behaviour of:
if (xml.Value.Equals("\n"))
or if xml.Value can legitimately be null:
if ("\n".Equals(xml.Value))

C# Code Snipped [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Is there any control for auto complate my code in textbox at runtime?
There is a textbox in my form and when i want to write c# code at runtime.Can it be auto complete code in textbox?
You can check out Actipro SyntaxEditor and Quantum Whale Editor.NET. Both controls support C# editing with syntax highlighting and "intellisense" drop-downs.
In WinForms, the standard combo box control includes options for providing the auto-complete mechanism based on the items in the drop down list.
I am assuming, of course, that you are not trying to do something like Intellisense. Your question is not clear.

Categories