473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Validation on web page - Either Or scenario

Could someone please help me with some validation. I have to write code which
checks to see whether a dropdown list is populated with a value or a checkbox
is checked. I want the code to run on the on-click of a button.
My page has 1 dropdown list and two checkboxes. So I either want the user
to choose an item from the dropdownlist OR tick a checkbox(it doesn't matter
if they tick both checkboxes). I can't allow the user to fill in the
dropdownlist and tick a checkbox.

Im pretty new to coding and im not sure what is the best way to do this. Can
I use a custom validator or would I be better putting it on the on-click
event of the button on the code behind page. I would also like the error
messages to appear in my Error Summary which is in a panel at the bottom of
my page.

This is the event ill probably need to place my code
private void Button1_Click(object sender, System.EventArgs e)
{
//Validate whether a item is selected in dropdown list OR a one/both
checkboxes is checked. Cant allow user to check a checkbox and choose an item
from the dropdown list
}

Could someone please help me write this code, im really not sure at all.

Here is the html code. for the page im using.

<table style="WIDTH: 305px; HEIGHT: 102px" height="102" width="305"
border="2">
<tr>
<td style="HEIGHT: 31px"><asp:dropdownlist id="DropDownList1" runat="server"
Width="231px">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Blue">Blue</asp:ListItem>
<asp:ListItem Value="Yellow">Yellow</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:dropdownlist></td>
</tr>
<tr>
<td style="HEIGHT: 31px"><asp:checkbox id="CheckBox2" runat="server"
Text="No Colour"></asp:checkbox>
<asp:checkbox id="CheckBox1" runat="server" Text="Any Colour"></asp:checkbox>
</td>
</tr>
<TR>
<TD><asp:button id="Button1" runat="server" Text="Button"></asp:button></TD>
</TR>
<tr><td>
<asp:panel id="pnMessagePanel" runat="server" Height="45px" Width="98.13%">
<asp:ValidationSummary id="vsSummaryOfErrors" runat="server" Width="897px"
Height="8px" BackColor="#ffffcc">
</asp:ValidationSummary>
</asp:panel>
</td></tr>
</table>

Thanks very much for any help anyone can give me
Jul 21 '05 #1
0 917

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hernán Castelo | last post by:
should i to validate all the "Request"s calls like Request.FORM("...") and Request.Cookies("...") ???? if it is so, i have to see inside every "Input" elements like "Text" and even "Hidden"...
4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
0
by: Matthias Lohrer | last post by:
Hi, I'm playing around with the possibilities of Page.ParseControl. Thanks to Kirk Allen Evans I got my example running (Posting Juli, 17, "Re: Generating ASP.NET-Controls with XSLT...
3
by: Ben | last post by:
Hi, I have a page with a datagrid that you have to scroll to see. I'm using the StrengthControls SmartScroller as recommended to maintain my scroll position. Anyway, inside the datagrid I have...
2
by: Ing. Rajesh Kumar | last post by:
Hi everybody Validation controls are great but i have a scenario where i do not know how to use them so i am doing my validation on the server. Let's say I have a Web Form with : Two Textboxes :...
3
by: msnews.microsoft.com | last post by:
Hi All, I m facing problem in Server Side Validation. For Example The Scenario is I have two fields on the page 1 Country Dropdown List 2 Province Textbox 3 State Dropdown List
0
by: Stephen | last post by:
Could someone please help me with some validation. I have to write code which checks to see whether a dropdown list is populated with a value or a checkbox is checked. I want the code to run on the...
0
by: jasondavidcarr | last post by:
Hello all, I have a "comments" page that contains three sections; the article to be commented on is on top, followed by previous comments, and on the bottom a place to add new comments. It's a...
6
by: Jon Paal | last post by:
validation doesn't fire what's missing ????? /////// ---- code -----/////////////////////////// Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.