<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="proj1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
<meta content=C# name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5 name=vs_targetSchema>
</HEAD>
<body MS_POSITIONING="GridLayout">
<h3>
<font face="Verdana">Bug Report</font> </H3>
<form id="frmBugs" method="post" runat="server">
<table bgcolor=gainsboro cellpadding=10>
<tr valign=top>
<td colspan=3>
<!-- Display error message -->
<asp:Label ID="lblMsg"
Text = "Please report your bug here"
ForeColor="red" Font-Name="Verdana"
Font-Size="10" Runat=server></asp:Label>
<br >
</td>
</tr>
<tr>
<td align=right>
<font face=Verdana size=2>Book</font>
</td>
<td>
<!-- Drop down list with books -->
<asp:DropDownList ID=ddlBooks Runat=server>
<asp:ListItem>-- Please Pick A Book --</asp:ListItem>
<asp:ListItem>
Teach Yourself c++ in 21 Days
</asp:ListItem>
<asp:ListItem>
Teach Yourself c++ in 24 hours
</asp:ListItem>
<asp:ListItem>TY C++ int 10 min</asp:ListItem>
</asp:DropDownList>
</td>
<!-- validator for the drop down -->
<td align=center rowspan=1>
<asp:RequiredFieldValidator
id="reqFieldBooks"
ControlToValidate="ddlBooks"
Display="Static"
InitialValue="--Please Pick A Book--"
Width="100%" Runat=server>
Please choose a book
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align=right>
<!-- Radio Buttons For The Edition -->
<font face=Verdana size=2>Edition:</font>
</td>
<td>
<asp:RadioButtonList ID=rblEdition
RepeatLayout="Flow" Runat=server>
<asp:ListItem>1st</asp:ListItem>
<asp:ListItem>2nd</asp:ListItem>
<asp:ListItem>3rd</asp:ListItem>
<asp:ListItem>4th</asp:ListItem>
</asp:RadioButtonList>
</td>
<!-- Validator for editions -->
<td align=center rowspan=1>
<asp:RequiredFieldValidator
id="reqFieldEdition"
ControlToValidate="rblEdition"
Display=Static
InitialValue=""
Width="100%" Runat=server>
Please pick an edition
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align=right style="HEIGHT: 97px">
<font face=Verdana size=2>Bug:</font>
</td>
<!-- Multi line text for bug entry -->
<td style="HEIGHT : 97px">
<asp:TextBox ID=txtBug Runat=server Width=183px TextMode=MultiLine Height=68px>
</asp:TextBox>
</td>
<!-- Validator for texbox -->
<td style="HEIGHT : 97px">
<asp:RequiredFieldValidator
id="reqFieldBug"
ControlToValidate="txtBug"
Display="Static"
Width="100%" Runat="server">
Please provide bug details
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID=btnSubmit Text="SubmitBug" Runat=server></asp:Button>
</td>
<td></td>
</tr>
</table>
</form>
</body>
</HTML>
Ok, i put here all of the code , so maybe someone will try it out. The problem is that when i don't select anything from the book list, it doesn't show the error message. But works fine for the others.
Oh, and the button submit has this code_behind attached to it :
protected void btnSubmit_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
lblMsg.Text = "Page is Valid!";
}
else
{
lblMsg.Text = "Some of the required fields are empty";
}
}
The weird thing is that in Firefox if not all of the fields are valid it says: "Some of the required fields are empty". In IE it doesn't(why?). But they both show "Page is Valid! " if all the fields are correct .
So, any ideea about y that error message isn't showing ? for the book list?