Cannot successfully add a Button to an ascx User Control

15 views Asked by At

I am attempting to update an existing ASP/MVC Web Site by adding a user control. I would ultimately like to add this user control to several of the Master Pages as it's an "Accept cookies banner" for the site.

As a side note, one of the changes I've made is to update the Sites .csproj file to set the value of MvcBuildViews to true:

 `<MvcBuildViews>true</MvcBuildViews>`

Before I add a Button, the web site loads ok initially and I see my banner at the bottom displaying my cookie message:

enter image description here

Then as my next step, I add a button, as shown below to allow the site visitors to accept the use of cookies

`
<link rel="stylesheet" type="text/css" href="../../Content/NBS/css/cookienotice.css" />
<asp:MultiView ID="CookieSet" runat="server" ActiveViewIndex="0">
    <asp:View ID="CookieView" runat="server">
        <asp:Label ID="CookieNoticeLabel" runat="server" CssClass="cookieNotice">By     clicking "Accept", you agree to our use of cookies. We use cookies to provide you with a     great experience and to help our website run effectively.</asp:Label>
        <asp:Button ID="Button2" runat="server" Text="Button" />
    </asp:View>
</asp:MultiView>
`

Below is a view of the User control in the designer after I've added a button:

enter image description here

At this point, the website no longer loads and I begin to get these errors in the Output Window:

Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll

Can someone please tell me why adding this button causes me an issue? Is there someway to debug this more completely, so that I can see if I'm missing a reference, perhaps?

As I mentioned above, I've tried setting MvcBuildViews to true:

 `<MvcBuildViews>true</MvcBuildViews>`

I see in the browser the error message:

      Failed to load resource: the server responded with a status of 500 () 

This may well be the issue, but I don't know what resource it's failing to load?

I am looking over the web for this error and the error:

Exception thrown: 'System.Web.HttpException' in System.Web.dll

Trying to understand what I'm not loading or missing in my web site solution.

0

There are 0 answers