.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Interview Question >> ASP.Net >> Post New Question Subscribe to Interview Questions

How to validate the listbox for the duplicate values from textbox.

Posted By :Ashutosh Jha     Posted Date :July 30, 2014    Points :40   Category :ASP.Net 
It can be done like below-

on the button click event of your add button you can check, if the already entered value and the textbox values are same or not. if both are same, don't allow it else write the new value like below-

foreach(listItem item in ListBox.Items)
if(Item.Text != txtbox1.Text)
//add the new value;

You can also find related Interview Question to How to validate the listbox for the duplicate values from textbox.  below: 

How do we validate numeric values in javascript?

Using evt.which or event.keyCode

the value will be numeric if it is between 47 and 58 (More...)

How To Validate If TextBox Contains A Valid Date?


ControlToValidate="txtOnlyValidDate" ErrorMessage="CompareValidator"
Operator="DataTypeCheck" Type="Date">


How can I screen input in a textbox?

Yes, For this, it's usually best to start by subclassing the TextBox control so that your solution is reusable within your project (or outside your project). Override OnTextChanged, or for more control, OnKeyPress and OnKeyDown. OnKeyPress fires for printable characters; OnKeyDown fires for all key combinations. Both of these offer a Handled property in the event arguments parameter, which you can set to True to cancel the event. (More...)

What is the difference between ListBox (Filled with data) and DropDownList (Filled with data), in terms of SelectedIndex property?

The default value of the SelectedIndex property of the Listbox is -1, which indicates that no item is selected in the Listbox. However, the DropDownList control overrides this property and sets the default value to 0, which indicates the first item in the list. (More...)

Does ViewState is responsible for maintaining data across the Page Post Back for Postback controls (like textbox, dropdownlist) and non-postbackcontrols(like label)?

It is false. For NonPostback controls it is true but for postback controls, ASP.NET retrieves their values one by one from the HTTP request and copies them to the control values while creating the HTTP response. (More...)

Can you control concatenation of string values with null values?

Concatenation of string values with null values results either null value or string value.
We can control that by setting CONCAT_NULL_YIELDS_NULL on or off.
When it is set to ON, the concatenation will result null and when it is set to OFF, it will result the string.
Setting it ON,
print 'testing' + NULL; --results NULL and prints nothing

Setting it OFF,

print 'testing' + NULL; -- results testing and prints the same (More...)

How to validate a Email-address, in Form using JavaScript?

We can validate it through the reg expressions. For example we can declare all the reg expressions of the email in a variable as follows.

var reg = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/; We need to compare the actual value with this expression for the validation. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend