An exception of type System.FormatException occurred in mscorlib.dll but was not handled in user c

Last Reply on Mar 18, 2016 01:39 AM By alibasha

Posted on Mar 16, 2016 05:36 AM

Hello,

            I dont understand why I am getting this issue even there is no type/data conversion error in my code. I just converted from 2.0 to 4.0 and with latest third party controls. I am getting the exception in the master page (design) exactly in the <td> which is given below. Please help

 MainMaster.master

 </tr>
                                    <tr> 
                                        <td class="banner" style="background-image: url(<%= LeftBorder() %>);">&nbsp;</td> 

Code Behind

 

Protected ReadOnly Property LeftBorder() As String
        Get
            Return ResolveUrl(LeftBorderSrc)
        End Get
    End Property

 

Private Const LeftBorderSrc As String = _
            "~/Images/MasterPages/LeftBorder.gif"

 

Results 1 - 5 of 11 123
Posted on Mar 16, 2016 05:36 AM
Hi @alibasha,
Please try the following

System.Web.HttpException' occurred in System.Web.dll but was not handled in user code

It might help you.

Cheers Andrea.

Posted on Mar 16, 2016 05:42 AM

Hi,

Will you please share your code where are you getting error


Posted on Mar 16, 2016 07:00 AM

Sure, I will share the complete code. Just to inform, exception is coming in design page (style="background-image: url(<%= LeftBorder() %>) ) which is frustating me.

Details of exception..

{"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."}

An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code

 

<%@ Master Language="VB" Inherits="Nestle.FMD.WebApp.MainMasterPage" Codebehind="MainMasterPage.master.vb" %>
<%@ Register Src="../UserControls/ucFooter.ascx" TagName="ucFooter"  TagPrefix="uc2" %>
<%@ Register Src="../UserControls/ucHeader.ascx" TagName="ucHeader"  TagPrefix="uc1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="HeadMasterPage" runat="server">
    <title>FMD</title>
    <link href="/App_Themes/FMD/Fmd.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">
        
        function displayProgressBar(){
            var o = document.getElementById('imgLoading');

            if (o != 'undefined'){
        	    o.style.display = 'block';
            }
        }   

    </script>
    <script type="text/javascript" src="../../scripts/common.js"></script>
</head>
<body>
    
    <form id="form1" runat="server" onsubmit="DisplayWaiting(this)">
   <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

          <table width="100%" border="0"  style="height:100%;" cellpadding="0" cellspacing="0">
            <tr>
                <td id="banner" valign="top" colspan="2">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="banner" style="height:100%;background-image: url(<%= BannerBackGroundURL() %>);">
                    <!--<table width="100%" border="0" cellpadding="0" cellspacing="0" class="banner" style="background-color:#4477b3;">                        -->
                        <tr>
                             <td align="left"><img src="<%=BannerURL() %>" alt="Banner" id="IMG1" onclick="return IMG1_onclick()"/>&nbsp;</td>
                            <!--td align="center" width="100%"><img style="position:absolute;" src="<%=BannerLeftURL() %>"/></td-->
                        </tr>
                    </table>
                    
                </td>
            </tr>
            <tr style="height:100%;" >
                <td>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">
                        <tr>
                            <td width="50px" bgcolor="#4477b3">&nbsp;</td>
                            <td valign="top">
                                <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td width="100%" colspan="3"><uc1:ucHeader ID="ucHeader1" runat="server" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><img src="<%=LeftAngle() %>"/></td>
                                        <td class="banner" width="100%" style="background-image: url(<%= TopBorder() %>);">&nbsp;</td> 
                                    </tr>
                                    <tr> 
                                        <td class="banner" style="background-image: url(<%= LeftBorder() %>);">&nbsp;</td> 
                                       <td width="100%" height="100%">
                                             <table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">
                                                    <tr height="100%">
                                                        <td colspan="2" height="100%" width="100%">
                                                             <div id="divContent" style="overflow:auto;height:100%;">
                                                            <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" ></asp:contentplaceholder>
                                                           </div> 
                                                       </td>
                                                    </tr>
                                             </table>
                                        </td> 
                                    </tr>
                                    <tr>
                                        <td><img src="<%=BottomAngle() %>"/></td>
                                        <td class="banner" width="100%" style="background-image: url(<%= BottomBorder() %>);">&nbsp;</td> 
                                    </tr> 
                                    <tr>
                                        <td colspan="3">
                                            <uc2:ucFooter ID="UcFooter1" runat="server" />            
                                        </td>
                                    </tr>                                      
                                </table> 
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

 

'----------------------------------------------------------------------------------------
' Copyright (C) 2007 NESTLE R&D
' All rights reserved.
' Author : MAZ
'----------------------------------------------------------------------------------------
Imports Nestle.FMD.BusinessEntities
Imports Nestle.FMD.BusinessFacade
Imports Nestle.FMD.WebApp.UIProcess
Imports Nestle.FMD.Common
Imports System.Web.UI.WebControls
Imports System.Globalization

''' <summary>
''' Application master page
''' </summary>
Partial Class MainMasterPage
    Inherits System.Web.UI.MasterPage

#Region "Private constants"

    ''' <summary>
    ''' Banner image
    ''' </summary>
    Private Const Banner As String = _
            "~/Images/MasterPages/Banner.gif"

    ''' <summary>
    ''' Banner left image
    ''' </summary>
    Private Const BannerLeft As String = _
            "~/Images/MasterPages/BannerLeft.gif"

    ''' <summary>
    ''' Banner back image
    ''' </summary>
    Private Const BannerBackGround As String = _
            "~/Images/MasterPages/BackGround2.gif"

    ''' <summary>
    ''' left angle image
    ''' </summary>
    Private Const LeftAngleSrc As String = _
            "~/Images/MasterPages/LeftAngle.gif"

    ''' <summary>
    ''' left border image
    ''' </summary>
    Private Const LeftBorderSrc As String = _
            "~/Images/MasterPages/LeftBorder.gif"

    ''' <summary>
    ''' Top border image
    ''' </summary>
    Private Const TopBorderSrc As String = _
            "~/Images/MasterPages/TopBorder.gif"

    ''' <summary>
    ''' Bottom border image
    ''' </summary>
    Private Const BottomBorderSrc As String = _
            "~/Images/MasterPages/BottomBorder.gif"

    ''' <summary>
    ''' bottom angle image
    ''' </summary>
    Private Const BottomAngleSrc As String = _
            "~/Images/MasterPages/BottomAngle.gif"

    ''' <summary>
    ''' separator image
    ''' </summary>
    Private Const SeparatorSrc As String = _
            "~/Images/MasterPages/Separator.gif"

    ''' <summary>
    ''' line separator image
    ''' </summary>
    Private Const LineSeparatorSrc As String = _
            "~/Images/MasterPages/LineSeparator.gif"

#End Region

#Region "Public events"

    ''' <summary>
    ''' Menu delegate
    ''' </summary>
    ''' <param name="sender">event sender</param>
    ''' <param name="e">event arguments</param>
    Public Delegate Sub MainMenuEventHandler(ByVal sender As Object, _
            ByVal e As EventArgs)

    ''' <summary>
    ''' Redirect to search page
    ''' </summary>
    ''' <param name="sender">event sender</param>
    ''' <param name="e">event arguments</param>
    Private Sub MainMenuSelected(ByVal sender As Object, _
            ByVal e As EventArgs)
        Server.Transfer(PageName.Search)
    End Sub

#End Region

#Region "Protected properties"

    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property BannerURL() As String
        Get
            Return ResolveUrl(Banner)
        End Get
    End Property


    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property BannerLeftURL() As String
        Get
            Return ResolveUrl(BannerLeft)
        End Get
    End Property


    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property BannerBackGroundURL() As String
        Get
            Return ResolveUrl(BannerBackGround)
        End Get
    End Property

    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property LeftAngle() As String
        Get
            Return ResolveUrl(LeftAngleSrc)
        End Get
    End Property

    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property LeftBorder() As String
        Get
            Return ResolveUrl(LeftBorderSrc)
        End Get
    End Property

    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property TopBorder() As String
        Get
            Return ResolveUrl(TopBorderSrc)
        End Get
    End Property


    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property BottomBorder() As String
        Get
            Return ResolveUrl(BottomBorderSrc)
        End Get
    End Property

    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property BottomAngle() As String
        Get
            Return ResolveUrl(BottomAngleSrc)
        End Get
    End Property

    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property Separator() As String
        Get
            Return ResolveUrl(SeparatorSrc)
        End Get
    End Property


    ''' <summary>
    ''' Image property
    ''' </summary>
    Protected ReadOnly Property LineSeparator() As String
        Get
            Return ResolveUrl(LineSeparatorSrc)
        End Get
    End Property

#End Region

#Region "Private properties"

    ''' <summary>
    ''' get the fmd page
    ''' </summary>
    Private ReadOnly Property CurrentFmdPage() As FmdPage

        Get
            Return CType(Me.Page, FmdPage)
        End Get

    End Property

#End Region

End Class

 


Posted on Mar 16, 2016 07:26 AM Modified on on Mar 16, 2016 07:26 AM

Hi,

I am not getting such error on the Page,

I would suggest try the same on other page

HTML

<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td class="banner" style="background-image: url(<%= LeftBorder() %>);">
            &nbsp;
        </td>
    </tr>
</table>

VB

Private Const LeftBorderSrc As String = _
        "~/Images/MasterPages/LeftBorder.gif"
Protected ReadOnly Property LeftBorder() As String
    Get
        Return ResolveUrl(LeftBorderSrc)
    End Get
End Property

 


Posted on Mar 16, 2016 08:49 AM

Hello,

           Thanks for your kind reply. I would try and get back to you. Thanks.

 

Best Reagrds

Ali