I am new to webforms and am getting an error while trying to compile webform1.aspx which is a form next to the site master form:
I am trying to get in my headers and footers and the fixed set of navigation buttons in my webpage
I am getting the following error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'site1_master' does not contain a definition for 'LinkButton4_Click' and no accessible extension method 'LinkButton4_Click' accepting a first argument of type 'site1_master' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 55:
Line 56:
Line 57: <asp:LinkButton class="nav-link" ID="LinkButton4" runat="server"
Line 58: OnClick="LinkButton4_Click">View Books</asp:LinkButton>
Line 59:
Source File: D:\KUD Venkat\source\repos\ELibraryManagement\LibraryManagementSystem\Site1.Master Line: 57
Here is my code for Site1.master:
<html>
<head runat="server">
<title></title>
<!-- Bootstrap css -->
<link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<!-- Datatable css -->
<link href="DataTables/css/jquery.dataTables.min.css" rel="stylesheet" />
<!-- FontAwesome css -->
<link href="FontAwesome/css/all.css" rel="stylesheet" />
<!-- Bootstrap Bundle -->
<script src="Bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Popper js -->
<script src="Bootstrap/js/popper.min.js"></script>
<!-- Bootstrap js -->
<script src="Bootstrap/js/bootstrap.min.js"></script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="#">
<img src="imgs/books.png" width="30" height="30"/>
E-Library
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="#navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="homepage.aspx">Home</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Terms</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item active">
<asp:LinkButton class="nav-link" ID="LinkButton4" runat="server"
OnClick="LinkButton4_Click">View Books</asp:LinkButton>
</li>
<li class="nav-item active">
<asp:LinkButton class="nav-link" ID="LinkButton1" runat="server"
OnClick="LinkButton1_Click">User Login</asp:LinkButton>
</li>
<li class="nav-item active">
<asp:LinkButton class="nav-link" ID="LinkButton2" runat="server"
OnClick="LinkButton2_Click">Sign Up</asp:LinkButton>
</li>
<li class="nav-item active">
<asp:LinkButton class="nav-link" ID="LinkButton3" runat="server"
OnClick="LinkButton3_Click">Logout</asp:LinkButton>
</li>
<li class="nav-item active">
<asp:LinkButton class="nav-link" ID="LinkButton7" runat="server"
OnClick="LinkButton7_Click">Hello user</asp:LinkButton>
</li>
</ul>
</div>
</nav>
</div>
<!-- Main Content Place Holder-->
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<!-- Main Content Place Holder-->
<footer>
<p> © All right Reserved. <a class="footerlinks" href="#"
target="_blank">TataSteel</a> </p>
</footer>
</form>
</body>
</html>
My code in Web Form1.aspx:
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="LibraryManagementSystem.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>
This is our Content webform
</h1>
</asp:Content>
I am trying to get in my header and footer and the corresponding menu buttons. However I am getting the error. What could be wrong . Could you help?
The solution should have the headers and footers along with the navigation buttons.
Related
So I am using asp.net razor pages and I want to pass a property from one of my page models to be used in the asp-route-id tag helper in the _layout page. I tried injecting the specific page model onto the _layout page and accessing it through #Model tag, when i use this and hover over the nav bar, the route id i want to show comes up, but when i click on it i get this error:
and if I use viewdata, it disappears after clicking on a nav item and becomes null.
_layout.cshtml(shared)
#model VescovererWebApp.Pages.AccountModel
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>#ViewData["Title"] - VescovererWebApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index"><img id="logo" src="~/Logo/vescoverer.png" /></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<partial name="_LoginPartial" />
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a id="cu" class="nav-link text-dark" asp-area="" asp-page="/Account" asp-route-id="#Model.currentUserID">Account</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Vescover" asp-route-id="#Model.currentUserID">Vescover</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Vescovered" asp-route-id="#Model.currentUserID">Vescovered</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Verify" asp-route-id="#Model.currentUserID">Verify</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
#RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
© 2021 - VescovererWebApp - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
#RenderSection("Scripts", required: false)
</body>
</html>
<style>
#logo {
height: 40px;
width: 40px;
}
</style>
try to use AccountModel as a base class
public class VescoveredModel : AccountModel
or you can create interface IAccountModel
public class AccountModel:IAccountModel
and
public class VescoveredModel : IAccountModel
and change layout model
#model VescovererWebApp.Pages.IAccountModel
you have two chose:
1.with button
<form method="post" asp-page="Order" asp-page-handler="Details">
<input type="hidden" name="Id" value="#item.Id">
<input type="submit" value="Show" >
</form>
2.with tag a
add #addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers to _ViewImports.cshtml
and use
<a asp-page="/Supplier" asp-route-id="#item.Id">Click</a>
I tried to find a solution to my problem but none matches my exact case.
My problem is the following: I am trying to add the Bootstrap 4 Navbar to my Page, which works fine - it's showing up. But it doesn't have any click events, I can't click the buttons or write something in the search field.
I tried to load the jQuery before loading the bootstrap.css file but it didn't work either.
This is the loading order in my Site.Master:
<script src="/Scripts/jquery-3.3.1.js"></script>
<script src="/Scripts/umd/popper.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/epadoc_Framework/EHR/Scripts/js/FontSize.js"></script>
<script src="/Scripts/global.js"></script>
<script src="/epadoc_Framework/EHR/Scripts/pk_script.js"></script>
<link href="/Content/bootstrap.css" rel="stylesheet" type="text/css"/>
It's the right Bootstrap version aswell.
Here is some default navbar to test if its working (it's just copied from Bootstrap):
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
And that is what it looks like in the header of the page:
As you can see it's showing up normally, but I just can't interact with it, I don't even get the hover effect when I mouseover the bar.
Any ideas what is going wrong here?
Try placing the .css in the head of the document like so.
<!DOCTYPE html>
<html lang="en">
<head>
<link href="/Content/bootstrap.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
//Your content
<script src="/Scripts/jquery-3.3.1.js"></script>
<script src="/Scripts/umd/popper.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/epadoc_Framework/EHR/Scripts/js/FontSize.js"></script>
<script src="/Scripts/global.js"></script>
<script src="/epadoc_Framework/EHR/Scripts/pk_script.js"></script>
</body>
I'm doing an C# ASP.NET web application, just in my learning stage.
I have a navbar in my Site.Master and when I am in my Default.aspx (/~), the image can be seen.
But when I change page eg. to (~/Account/Register) the image can not be found.
The code to Image in my navbar:
<img style="margin:10px; margin-left:30px;" width="30px" height="30px" src="logo_abstract.png">
To see the whole code for my Site.Master and MainContent , here it is the relevant code, containing the above code:
<div class="navbar navbar-inverse navbar-fixed-top">
<img style="margin:10px; margin-left:30px;" width="30px" height="30px" src="brain_stransparent_abstract.png">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/">TestApp</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contat</a></li>
</ul>
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a runat="server" href="~/Account/Login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li>
<a runat="server" href="~/Account/Manage" title="Manage your account">
<img src="http://placehold.it/18x18" class="profile-image img-circle">
<%: Context.User.Identity.GetUserName() %> <b class="caret"></b>
</a>
</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>
<div class="container body-content">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
<hr />
<footer>
<p>© <%: DateTime.Now.Year %> - Test</p>
</footer>
</div>
I think, I need to set a path to my image, that is the same path from everywhere, but I don't know any word for this, to google or something.
This is because at runtime the path in internal pages can't locate the images so for any link or image paths you should use Page.ResolveUrl method
<img style="margin:10px; margin-left:30px;" width="30px" height="30px" src="<%= Page.ResolveUrl("~/Images/logo_abstract.png"); %>">
Hope it helps
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
ok. Where to begin with. I have just purchased this nice theme which I am integrating into ASP.NET web forms.
So far so good the theme is working nice, However when I add more pages the menu and the drop down menus are not working.
I have a default.aspx and then when I call another page I see the menu but the menu is not working and the drop down menus are not working too.
What am I missing here? I am using master pages.
Here is the master page code.
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Tutorial1.SiteMaster" %>
<%# Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="Head1" runat="server">
<meta charset="utf-8">
<title>PhaseGroup Customer Administration Panel</title>
<link rel="shortcut icon" href="favicon.gif">
<!---CSS Files-->
<link rel="stylesheet" href="css/master.css">
<link rel="stylesheet" href="css/tables.css">
<!---jQuery Files-->
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jquery-ui-1.8.17.min.js"></script>
<script src="js/styler.js"></script>
<script src="js/jquery.tipTip.js"></script>
<script src="js/colorpicker.js"></script>
<script src="js/sticky.full.js"></script>
<script src="js/global.js"></script>
<script src="js/flot/jquery.flot.min.js"></script>
<script src="js/flot/jquery.flot.resize.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<link href="Styles/mGrid.css" rel="stylesheet" />
<!---Fonts-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Ubuntu:500' rel='stylesheet' type='text/css' />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--[if lte IE 8]>
<script language="javascript" type="text/javascript" src="js/flot/excanvas.min.js"></script>
<![endif]-->
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="Form1" runat="server">
<!--- HEADER -->
<div class="header">
<a href="dashboard.html">
<img src="../img/logo.png" alt="Logo" /></a>
<div class="styler">
<ul class="styler-show">
<li>
<div id="colorSelector-top-bar"></div>
</li>
<li>
<div id="colorSelector-box-head"></div>
</li>
</ul>
</div>
</div>
<div class="top-bar">
<ul id="nav">
<li id="user-panel">
<img src="../img/nav/usr-avatar.jpg" id="usr-avatar" alt="" />
<div id="usr-info">
<p id="usr-name">Welcome back, Michael.</p>
<p id="usr-notif">You have 6 notifications. View</p>
<p>PreferencesProfileLog out</p>
</div>
</li>
<li>
<ul id="top-nav">
<li class="nav-item">
<a href="../Products/ProductDetails1.aspx">
<img src="img/nav/dash-active.png" alt="" /><p>Dashboard</p>
</a>
</li>
<li class="nav-item">
<a href="analytics.html">
<img src="img/nav/anlt.png" alt="" /><p>Analytics</p>
</a>
</li>
<li class="nav-item">
<a href="tables.html">
<img src="img/nav/tb.png" alt="" /><p>Tables</p>
</a>
</li>
<li class="nav-item">
<a href="calendar.html">
<img src="img/nav/cal.png" alt="" /><p>Calendar</p>
</a>
</li>
<li class="nav-item">
<a href="widgets.html">
<img src="img/nav/widgets.png" alt="" /><p>Widgets</p>
</a>
</li>
<li class="nav-item">
<a href="grid.html">
<img src="img/nav/grid.png" alt="" /><p>Grid</p>
</a>
<ul class="sub-nav">
<li>12 Columns</li>
<li>16 Columns</li>
</ul>
</li>
<li class="nav-item">
<a href="filemanager.html">
<img src="img/nav/flm.png" alt="" /><p>File Manager</p>
</a>
</li>
<li class="nav-item">
<a href="gallery.html">
<img src="img/nav/gal.png" alt="" /><p>Gallery</p>
</a>
</li>
<li class="nav-item">
<a href="icons.html">
<img src="img/nav/icn.png" alt="" /><p>Icons</p>
</a>
</li>
<li class="nav-item">
<a href="#">
<img src="img/nav/err.png" alt="" /><p>Error Pages</p>
</a>
<ul class="sub-nav">
<li>403 Page</li>
<li>404 Page</li>
<li>503 Page</li>
</ul>
</li>
<li class="nav-item">
<a href="typography.html">
<img src="img/nav/typ.png" alt="" /><p>Typography</p>
</a>
</li>
</ul>
</li>
</ul>
</div>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</form>
</body>
</html>
For starters, have you checked your debugger on the browser and are there any errors?
You're loading a lot of scripts and jquery stuff. The chances of a conflict are pretty high.
what's your css for the drop down menus look like? Are they jquery or pure css? By the structure looks like jquery.
Theres some stuff I don't like what you're doing there but it won't stop them from working. Anyway I digress..script errors?
It's likely working on one page and not others because your paths are wrong.
<script src="js/jquery-1.7.1.min.js"></script>
should be
<script src="/js/jquery-1.7.1.min.js"></script>
and so on for the other scripts and style references. Note that src="js is now src="/js. The / takes you back to the site root.
Without it, it will look in the current directory for a sub directory named js... but since you want the folder at the root of your project named js, you need to use /js.
first time here on StackOverflow and it's a pleasure to be here, hope to have a nice time with all off you and to help with anything I can.
Well the question I'm asking is just what I have put in the title, the thing is I'm using a Master Page with four User Controls to fill the Master Page witch works fine,but in one of the User Controls (Principal.ascx) I have put a PlaceHolder with witch I wish to change the data in it depending on the page that is being loaded, per example if I wish to load the Register Employee page, I would send that to the placeholder and show it or if I wish to load the login page I would send that to the place holder and show it. So the code I'm handling is:
MasterPage:
<%# Register Src="~/UserControl/Head.ascx" TagName="Head" TagPrefix="hdr" %>
<%# Register Src="~/UserControl/Foot.ascx" TagName="Foot" TagPrefix="ftr" %>
<%# Register Src="~/UserControl/Menu.ascx" TagName="Menu" Tagprefix="mnu" %>
<%# Register Src="~/UserControl/Principal.ascx" TagName="Principal" Tagprefix="prn" %>
<link rel="Stylesheet" type="text/css" href="~/Css/Styles.css" />
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<form runat="server" id="MainForm">
<div class="Container">
<hdr:Head runat="server" ID="hdrHead" />
<mnu:Menu runat="server" ID="menMenu" />
<prn:Principal runat="server" ID="priPincipal" />
<ftr:Foot runat="server" ID="ftrFoot" />
</div>
</form>
</body>
</html>
There is no code behind on the master page yet.
And on the Menu UserControl is a simple menu managed using JQuery UI, after I'm able to make the login page work with the UserControl I will try to make this menu dynamic and only show menu levels that are relevant to the user that access the page:
<link rel="Stylesheet" type="text/css" href="../Css/jquery-ui-1.10.0.css" />
<script src="../Js/jquery-1.9.1.js" type="text/javascript"></script>
<script src="../Js/jquery-ui-1.10.0.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#menu").menu();
});
</script>
<div class="MenuContainer">
<span style="margin: 20px 10px; padding: 5px;">
Bienvenido, Usuario.
</span>
<div class="Menu">
<ul id="menu">
<li>Inicio</li>
<li>Base de Conocimientos
<ul>
<li>Vista general</li>
<li>Agregar</li>
</ul>
</li>
<li>Documentación HGI
<ul>
<li>Documentos</li>
<li>Agregar</li>
</ul>
</li>
<li>Beneficios
<ul>
<li>Medio día libre</li>
<li>Vacaciones</li>
</ul>
</li>
<li>Mantenimiento
<ul>
<li>Códigos
<ul>
<li>Vista General</li>
<li>Agregar</li>
</ul>
</li>
<li>Configuraciones
<ul>
<li>Vista General</li>
<li>Agregar</li>
</ul>
</li>
</ul>
</li>
<li>Salir</li>
</ul>
</div>
</div>
And the UserControl where I want to load the content is calles Principal.ascx:
<div class="Contenido">
<asp:PlaceHolder runat="server" ID="PlaceHolder">
</asp:PlaceHolder>
</div>
I wish to display in the place holder a test text has fallows from the page default.aspx:
<span>
This is the test.
<span/>
none of the UserControls or the MasterPage have any type of code on there .cs pages.