I keep get an error when I load a ContentPage inside a fancybox:
Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/MasterPage/Modal.Master', verify content control's ContentPlaceHolderID attribute in the content page.
I have this in the MasterPage (some code omitted for simplification):
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Modal.master.cs"
Inherits="TransportadoraEDI.App.Modal" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8" />
<title></title>
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id="main-content">
<div style="width: 800px; height: 600px">
<asp:ContentPlaceHolder ID="cphConteudo" runat="server">
</asp:ContentPlaceHolder>
</div>
<!-- jQuery -->
<script src="../js/jquery.min.js"></script>
<script src="../js/init.js"></script>
<asp:ContentPlaceHolder ID="cphBlocoJs" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
And this code in a ContentPage (some code omitted for simplification):
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage/Modal.Master"
AutoEventWireup="true" CodeBehind="FormCadNotFis.aspx.cs" Inherits="TransportadoraEDI.App.Conemb.FormCadNotFis" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphConteudo" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphBlocoJs" runat="server">
</asp:Content>
How it's possible to the ContentPage look for a ContentPlaceHolder that doesn't even exists?
EDIT
My open fancybox function:
$(document).ready(function () {
function AbrirModal(url) {
$.fancybox.open({
fitToView: false,
autoSize: false,
href: url,
//width: _width,
//height: _height,
type: 'iframe',
transitionOut: 'none',
centerOnScroll: true,
hideOnOverlayClick: false,
padding: 0,
afterClose: function () {
parent.location.reload(true);
}
});
}; });
There is no ContentPlaceHolder named 'MainContent' in your master page,
A content place holder should be in your Master page like this:
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
And child pages like this:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>
Related
I am creating a Web Forms project with a Master Page. However, when I put a label on the master page (or any other control or html element) it does not display it on the web form. How can I fix this problem?
MasterPage:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="RWA.MasterPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form" runat="server">
<div>
<asp:ContentPlaceHolder ID="MasterPagePlaceHolder" runat="server">
<asp:Label ID="NameLabel" runat="server" Text="Label"></asp:Label>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Web Form:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master"
AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="RWA.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MasterPagePlaceHolder"
runat="server">
</asp:Content>
Fixed it, only needed to remove the control from the content placeholder
Jquery is not wrking when I am using form tag in asp.net controls.so whats the solution .I am trying multiple techniques but it does not work.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#bt1").click(function () {
$("#p1").hide(2000);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p runat="server" id="p1">this is asp.net</p>
<asp:Button ID="bt1" Text="click" runat="server"/>
</div>
</form>
</body>
</html>
As you are using ASP.NET and bt1 is a button server control you need to use Control.ClientID.
<%= bt1.ClientID %> will Gets the control ID for HTML markup that is generated by ASP.NET.
Use
$("#<%= bt1.ClientID %>").click(function () {
$("#<%= p1.ClientID %>").hide(2000);
});
OR
You can use ClientIDMode.Static mode then you can continue with your existing code. However I will not recommend it.
I have an ASP.NET project whose page starts with:
<head runat="server">
<meta charset="utf-8">
<title>Online SMS Choose</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link id="Link1" rel="stylesheet" runat="server" media="screen" href="~/css/tableStyle.css" />
<link id="Link2" rel="stylesheet" runat="server" media="screen" href="~/css/LoadingStyle.css" />
<link id="Link3" rel="stylesheet" runat="server" media="screen" href="~/css/selectStyle.css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function () {
$("#tabs").tabs();
});
$(function () {
$("#datepicker").datepicker();
});
</script>
</head>
Then my manager told me that I have to merge that project with another one. She gave me the code of the other project. That code doesn't have a head tag in it, but it has this at the start of the page:
<%# Page Title="Service Categories" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="service._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="content" id="Content">
Where do I put the <head> tag in this new project?
The first code snippet you provided is standard HTML markup and the second is ASP.NET markup as I am sure you are aware.
You can combine both of them in the following manner:
<%# Page Title="Service Categories" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="service._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
<title>Online SMS Choose</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link id="Link1" rel="stylesheet" runat="server" media="screen" href="~/css/tableStyle.css" />
<link id="Link2" rel="stylesheet" runat="server" media="screen" href="~/css/LoadingStyle.css" />
<link id="Link3" rel="stylesheet" runat="server" media="screen" href="~/css/selectStyle.css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function () {
$("#tabs").tabs();
});
$(function () {
$("#datepicker").datepicker();
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="content" id="Content">
........
You have already a head section in there:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
</asp:Content>
check your project for files, which put content into this PlaceHolder. If you want to define a <head> wrap it around this content placeholder. But then you need to check the contents of the other files and refactor it, so you do not define a head tag inside a head tag.
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
</asp:Content>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="content" id="Content">
// ...
</div>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
You can place the <head runat="server"></head> above the content..
Wich file are you supposed to put in the other?
One is using a masterpagefile and the other isn't.
I have a ASP.NET Application with a master site and content sites. in one of this content sites I have a Div with Controls and I want to try it make draggable with jQuery but I don't know how I can to this in ASP.NET because of the Control Id in asp.
here is my code:
master site:
...
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Styles/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="Script/jquery-1.8.2.js" type="text/javascript"></script>
<script src="Script/jquery-ui.js" type="text/javascript"></script>
<script>
$(function () {
$("#create_box").draggable();
});
</script>
</head>
<body>
<form id="mainform" runat="server">
<div class="gastzugang">
<asp:ContentPlaceHolder ID="lw_header" runat="server">
<!--Header-->
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="lw_content" runat="server">
<!--Content-->
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="lw_footer" runat="server">
<!--Footer-->
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
My Content Site:
<%# Page Title="" Language="C#" MasterPageFile="~/master.Master" AutoEventWireup="true" CodeBehind="CreateUser.aspx.cs" Inherits="lw_gastzugang.CreateUser" %>
<asp:Content ID="Content2" ContentPlaceHolderID="lw_content" runat="server">
<div class="createuser">
<div class="create_box">
<div class="newUser">
Benutzer Anlegen <br/>
<br/>
//Here are my Controls
<br/>
<asp:Button ID="btnAnlegen" runat="server" Text="Benutzer anlegen"
onclick="btnAnlegen_Click" />
</div>
</div>
</div>
</asp:Content>
I want to this:
http://jqueryui.com/droppable/
Just use jQuery UI draggable.
Make
ClientIDMode="static" in the asp.net Tag
Or Use
<script type="text/javascript">
$('#'+'<%=lw_content.ClientID%>').draggable();
</script>
You could take a look at hammer.js which covers a 'drag' style event:
https://github.com/EightMedia/hammer.js
The drag example there is at:
http://eightmedia.github.com/hammer.js/drag/
Now I don't know too much about ASP.NET but what I would try is applying the drag behaviour to anything with a .draggable class.
Hope that helps a little!
I have 2 master pages that are nested.this is main master page code for example:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPageMaster.master.cs" Inherits="MasterPageMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtMasterPageMaster" ClientIDMode="Static" runat="server"></asp:TextBox>
<div style="background-color:Aqua;height:40px;">
Some Text
</div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
and the nested master page:
<%# Master Language="C#" MasterPageFile="~/MasterPageMaster.master" AutoEventWireup="true"
CodeFile="MasterPageNested.master.cs" Inherits="MasterPageNested" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:Panel runat="server" ID="panelMain" BackColor="lightyellow">
<h2>
Child master</h2>
<asp:Panel runat="server" ID="panel1" BackColor="lightblue">
<p>
This is child master content.</p>
<asp:ContentPlaceHolder ID="ChildContent1" runat="server" />
</asp:Panel>
<asp:Panel runat="server" ID="panel2" BackColor="pink">
<p>
This is child master content.</p>
<asp:ContentPlaceHolder ID="ChildContent2" runat="server" />
</asp:Panel>
<br />
</asp:Panel>
</asp:Content>
and I create a page based on this nested master page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPageNested.master" AutoEventWireup="true" CodeFile="PageMasterPageNested.aspx.cs" Inherits="PageMasterPageNested" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ChildContent1" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ChildContent2" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Button" Height="66px"
onclick="Button1_Click" Width="196px" />
</asp:Content>
I want in click of Button1 get text of main master page.
How I can do this?
In PageMasterPageNested.aspx:
TextBox txtBox = this.Master.Master.FindControl("txtMasterPageMaster") as TextBox;
Should work. Give it a try. Hope it helps.
This works in any case. especially if you dont know or care how many master pages you nested. Hope it helps :)
MasterPage tmp = this.Master;
while (tmp.Master != null)
{
tmp = tmp.Master;
}
var control = tmp.FindControl("form1");