Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   ASP (http://www.programmingforums.org/forum32.html)
-   -   Problem with showing error (http://www.programmingforums.org/showthread.php?t=6370)

xavier Oct 11th, 2005 12:15 PM

Problem with showing error
 
:

<%@ 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?

maro25 Oct 12th, 2005 1:55 AM

I would guess that in one you are writing: "--Please Pick A Book--"
and in the other -- Please Pick A Book --

notice in the second the spaces between -- and the text

xavier Oct 12th, 2005 2:34 AM

Damn, that was it. Thanks :) . But now there still is something weird :
In IE , if i choose the first book from the list, it's all fine when i press submit. But in Firefox, it only works if i pick the last book :eek:

Also, there still is the thing when i press the button and if there are any more fields left unfilled , it should say : "Some of the required fields are empty" .. in firefox it works , in IE it doesn't :mad:

MrMan9879 Oct 13th, 2005 9:52 PM

Maybe you have another error that we can't find. Since IE is Microsoft, it tends to display microsoft made things a lot better than Netscape and FireFox etc. (For example: FrontPage built websites).

xavier Oct 15th, 2005 3:39 AM

No errors that i can find, just weird that one thing is displayed just in firefox an another just in IE .. oh well , that's it.


All times are GMT -5. The time now is 4:58 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC