locked
Invalid format exception RRS feed

  • Question

  • User-1507790905 posted
    Hello

    If I try to enter a new event and then click cancel without entering something, I receive
    the following error:

    Serverfehler in der Anwendung /ClubWebSite1.

    Die Eingabezeichenfolge hat das falsche Format.

    Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.

    Ausnahmedetails: System.FormatException: Die Eingabezeichenfolge hat das falsche Format.

    Quellfehler:

    Zeile 55:                 id = Request.QueryString("EventID")
    Zeile 56: If Not id Is Nothing Then
    Zeile 57: m_EventID = CInt(id)
    Zeile 58: Else
    Zeile 59: m_EventID = 1

    Quelldatei: C:\...........\ClubWebSite1\Events_View.aspx    Zeile: 57

    Stapelüberwachung:

    [FormatException: Die Eingabezeichenfolge hat das falsche Format.]
    Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +216
    Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) +93

    [InvalidCastException: Ungültige Konvertierung von der Zeichenfolge in Typ Integer.]
    Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) +251
    Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value) +1030
    ASP.events_view_aspx.get_EventID() in C:\Dokumente und Einstellungen\....\ClubWebSite1\Events_View.aspx:57
    ASP.events_view_aspx.Page_Load(Object sender, EventArgs e) in C:\Dokumente und Einstellungen\....\ClubWebSite1\Events_View.aspx:14
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
    System.Web.UI.Control.OnLoad(EventArgs e) +80
    System.Web.UI.Control.LoadRecursive() +49
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3730

    What can I do to handle or prevent this error?

    Thanks in advance,

    Xerxes24
    Sunday, February 19, 2006 1:06 PM

All replies

  • User1052258516 posted

    Replace Lines 55-59 with this:

    id = Request.QueryString("EventID")

    If Not id Is Nothing Then

    Try

    m_EventID = DirectCast(id, Integer)

    Catch

    m_EventID = 1

    End Try

    Else

    m_EventID = 1

    End If

    - Will
    www.willyd.ca

    Monday, February 20, 2006 3:02 PM
  • User-1476513399 posted

    The actual cause of this problem is as follows:

    From the Events page, click on Add New Event. This takes you to the Events_edit.aspx page.

    If you next click on Cancel, you will get the above error.

    This is because the Cancel action is trying to go to the Events_View page when in fact it should be going to events_calendar.aspx - where you started from.

    The are two places on the Events_edit.aspx page that need to be changed where the following two lines of code are - that have to do with Adding a new event:

    <Club:RolloverButton ID="apply1" CommandName="Insert" Text="Add Event" runat="server" />

    <Club:RolloverLink ID="Cancel" Text="Cancel" runat="server" NavigateURL='<%#

    "Events_view.aspx?EventID=" & Cstr(Eval("ID"))  %>' />

    The 2nd line needs to be:

    <Club:RolloverLink ID="Cancel" Text="Cancel" runat="server" NavigateURL='<%#

    "Events_calendar.aspx"  %>' />

    Again, there are two places where these lines of code exit, because there are Add Event / Cancel buttons at the top and bottom of the page.

    Now NOTE:

    If you start on the Events page, and click an event link on some date, this takes you to Events_view.aspx.  Now, if you then click on Edit .. you are again on the Events_edit.aspx page. From here, if you click Cancel, it works fine (no error) because it takes you back to the Events_view.aspx page where it should ... and the ID exists (not null).

    There is also another minor bug:

    From the Events page, click on Add New Event.

    This takes you to Events_Edit.aspx page.

    Now, click on Add New Event (on this page). You get a page not found error ... because ... its trying to go to Event_edit.aspx instead of Events_edit.aspx (the 's' is missing in the first case-no doubt a typo).

    <><><>

    Wednesday, March 22, 2006 4:13 AM