Ok basically I have a master page which has all the design in a Form with runat server as follows:
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<table style="font-family: Arial">
<tr>
<td colspan="2" style="width: 800px; height: 80px; background-color: #3399FF; text-align: center">
<h1>WebSite Header
</h1>
</td>
</tr>
<tr>
<td style="height: 500px; background-color: #66FFFF; width: 150px">
<h3>Menu</h3>
</td>
<td style="height: 500px; background-color: #9999FF; width: 650px">
<h3>content</h3>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<p>
</p>
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="background-color: #3399FF; text-align: center">
<b>Website Footer</b>
</td>
</tr>
</table>
</form>
</body>
</html>
Now I am trying to do a page using this master page and in this page I am initializing a CKEditor which apparently needs to be in a form with runat server to be able to function, as follows:
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="CkEditor.aspx.cs" Inherits="WebApplication5.CkEditor" %>
<%# Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<form id="form2" runat="server">
<div>
<div>
<CKEditor:CKEditorControl ID="CKEditor1" runat="server">
</CKEditor:CKEditorControl>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="lblText" runat="server" Text=" "></asp:Label>
</div>
</form>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
The Form however with the CKEditor in it is not allowing to be initialized because it is becoming a Nested Form, since the master page itself is bound in a form.
How can I prevent this please?
Your CKEditorControl will inherit the form from the master page.
First, move your asp:ContentPlaceHolder from the head tag:
<head runat="server">
<title></title>
<!--DON'T PUT IT HERE-->
</head>
<body>
<form id="form1" runat="server">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
...
Now you can remove the form2:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<!--<form id="form2" runat="server">-->
<div>
<div>
<CKEditor:CKEditorControl ID="CKEditor1" runat="server">
</CKEditor:CKEditorControl>
...
Related
How to show an image in ContentPlaceHolder4 on click of a Link Button which is placed on ContentPlaceHolder3.
I Have a Master Page and one content page. On master page i have a link INSTRUMENTS by clicking on which i am redirected to content page INSTRUMENTS. Now i have 10 LINK BUTTON controls on my Content Page and i want on the click of each link button corresponding image should open on same content page but in different CntentPlaceHolder. Please guide me how to add code for Link Button Click and how to render iamge on click of Link Button.
Following is the code i have added till now.
**This is My Master Page**
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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>
<style type="text/css">
.style1
{
}
.style2
{
width: 162px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div> <img src="IMAGES/main.png" style="background-color: #99FF99; border-top-color: #800000; width: 1082px; height: 105px;" />
</div>
HOME INSTRUMENTS LOGIN
ADDRESS
<table style="width: 100%; height: 288px; margin-top: 11px;">
<tr>
<td bgcolor="#FF0066" align="center" class="style2"
style="text-align: center; vertical-align: top;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
</asp:ContentPlaceHolder>
</td>
<td bgcolor="#33CCCC" class="style1">
<asp:ContentPlaceHolder ID="ContentPlaceHolder4" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</form>
</body>
</html>
**This is My Content Page**
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="INSTRUMENTS.aspx.cs" Inherits="INSTRUMENTS" %>
<asp:Content id="content3" ContentPlaceHolderID="head" runat="server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="lkbutton_click">Sitar</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton2" runat="server">Harmonium</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton3" runat="server">Tabla</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server">Drum</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton5" runat="server">Guitar</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton6" runat="server">Sarod</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton7" runat="server">Flute</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton8" runat="server">Santoor</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton9" runat="server" onclick="LinkButton9_Click">Keyboard</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton10" runat="server">LinkButton</asp:LinkButton>
</asp:Content>
<asp:content ID ="C2" ContentPlaceHolderID ="ContentPlaceHolder4" runat="Server">
<asp:Image ID ="I1" ImageUrl ="~/IMAGES/F.png" >
<asp:Image />
</asp:content>
in your design page use like this.
<asp:Content ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
<img id="img1" runat="server" />
</asp:Content>
and in code behind link button click event like below:
protected void lkbutton_click(object sender, EventArgs e)
{
img1.Src = "~/images/sonata-logo.png";
}
i tested it it's working fine.
but put the correct path of image then only it will show.
Thanks
<asp:LinkButton ID="LinkButton1" runat="server" width="250px" height="250">
<img runat="server" id="IL"src="~/Class/Adds/0/4.jpg" width="250" height="250" />
</asp:LinkButton>
With this you can change the picture with server code.
il.SRC = "~/Class/Adds/0/7.jpg"
I'm working on a project at the moment that I've recently taken over, which has the Umbraco CMS installed (4.7.1) and is written in ASP.net and I'm not really sure what I'm doing and have got stuck.
The CSS won't appear on one page, the ContactUs page (contact-us.aspx), but the CSS appears perfectly fine everywhere else, which I find really odd.
So my question is what do I need to do to get the CSS appearing on this page, like the others?
Here is the contact-us template:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="ContactUs.master.cs" Inherits="GreenHill.masterpages.ContactUs"
MasterPageFile="~/umbraco/masterpages/default.master"%>
<%# Register TagPrefix="gh" TagName="ProductNav" Src="~/usercontrols/ProductNav.ascx" %>
<%# Register TagPrefix="gh" TagName="ProductListing" Src="~/usercontrols/ProductListing.ascx" %>
<%# Register TagPrefix="gh" TagName="Twitter" Src="~/usercontrols/Twitter.ascx" %>
<asp:Content runat="server" ID="pageContent" ContentPlaceHolderID="content">
<div class="title">
<h1>
<asp:Literal ID="litTitle" runat="server"></asp:Literal></h1>
</div>
<div class="brown-border"></div>
<table class="content">
<tr>
<td class="left main-column">
<asp:Image runat="server" ID="imgHero" />
</td>
<td class="side-panel" rowspan="2">
<gh:Twitter runat="server" id="ucTwitter"></gh:Twitter><br />
</td>
</tr>
<tr>
<td>
<table class="small-table">
<tr>
<td class="left">
<h2>Contact Us</h2>
</td>
<td>
<h2>Say hi to the team</h2>
</td>
</tr>
<tr>
<td colspan="2">
<div class="brown-border small-table-separator"></div>
</td>
</tr>
<tr>
<td>
<asp:Literal runat="server" ID="litContent"></asp:Literal>
</td>
<td>
<form ID="form1" runat="server">
<div class="form">
<ul>
<li>
<asp:TextBox ID="txtName" runat="server" placeholder="Name"></asp:TextBox>
</li>
<li>
<span id="nameError" class="error-message" style="display:none;">Please enter your name.</span>
</li>
<li>
<asp:TextBox ID="txtEmail" runat="server" placeholder="Email"></asp:TextBox>
</li>
<li>
<span id="emailError" class="error-message" style="display:none;">Please enter your email address.</span>
</li>
<li>
<asp:TextBox ID="txtMessage" runat="server" Rows="5" TextMode="MultiLine" placeholder="Message"></asp:TextBox>
</li>
<li>
<span id="messageError" class="error-message" style="display:none;">Please enter the message.</span>
</li>
<li>
<asp:Literal ID="litMessage" runat="server"></asp:Literal>
</li>
<li>
<asp:Button CssClass="button" ID="btnSend" runat="server" Text="Send" OnClientClick="return validate()" />
</li>
</ul>
</div>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script>
$(document).ready(function () {
RelatedProducts.addGap();
});
</script>
</asp:Content>
And here is the base template:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Base.master.cs" Inherits="GreenHill.masterpages.Base" %>
<!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>Greenhill Timbers</title>
<asp:contentPlaceholder id="head" runat="server" />
<link rel="stylesheet" type="text/css" href="/css/global.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script src="/scripts/navigation.js" type="text/javascript"></script>
<script src="/scripts/tinker.js" type="text/javascript"></script>
<script type="text/javascript" src="/scripts/jcarousellite_1.0.1.pack.js"></script>
<script type="text/javascript" src="/scripts/captify.tiny.js"></script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f07fd7a7ce8f226"></script>
<script type="text/javascript">
//jCarouselLite
$(function () {
$(".slider").jCarouselLite({
//btnNext: ".next",
auto: 3000,
visible: 1,
speead: 1000
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="top-nav">
<!--Contact Us | Sitemap | Example-->
</div>
<div class="brown-border"></div>
<div class="header">
<img class="logo" src="/images/GH_Top_Logo.png" />
<asp:Repeater ID="rptNav" runat="server" OnItemDataBound="rptNav_DataBound">
<HeaderTemplate>
<ul class="main-nav">
<li>Home</li>
</HeaderTemplate>
<ItemTemplate>
<li class="separator">|</li>
<li>
<asp:HyperLink ID="linkPage" runat="server">
<asp:Literal ID="litPageTitle" runat="server"></asp:Literal>
</asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</div>
<div class="brown-border"></div>
<div class="main-outer">
<div class="main">
<asp:ContentPlaceHolder ID="content" runat="server">
</asp:ContentPlaceHolder>
<div class="footer-logo">
<img src="/images/GH_Stamp_Footer.png" />
</div>
</div>
<p class="footer">© 2011 GREENHILL TIMBERS P/L | 170 Settlement Road, Thomastown 3074 Australia | P. 03 9465 9875 | <a class="footer-link" href="mailto:info#greenhilltimbers.com.au">info#greenhilltimbers.com.au</a></p>
</div>
</form>
</body>
</html>
And finally there default.master template:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="default.master.cs" Inherits="umbraco.presentation.masterpages._default" %>
<asp:ContentPlaceHolder ID="ContentPlaceHolderDefault" runat="server">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder id="content" runat="server">
</asp:ContentPlaceHolder>
You have:
MasterPageFile="~/umbraco/masterpages/default.master"
Which means your Contact Us page is inheriting from the default Umbraco master page, and not your base master page.
I just realized in typing this that your question is a week old, but I'm going to answer anyway. :)
i have page and add Ajax extension but it throwing error for me
i am using master page so this page doesn't have <head>
page code
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" runat="server" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 100%">
<tr>
<td colspan="5" style="text-align: center; height: 20px;">Search </td>
</tr>
<tr>
<td style="text-align: center; height: 20px;">Ticket number</td>
<td style="text-align: center; height: 20px;">Client name</td>
<td style="text-align: center; height: 20px;">Address</td>
<td style="text-align: center; height: 20px;">Assigned to</td>
<td style="text-align: center; height: 20px;">Date</td>
</tr>
<tr>
<td style="width: 157px">
<asp:TextBox ID="txt_incID" runat="server" Width="146px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txb_ClientName" runat="server" Width="146px"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddl_Address" runat="server" Width="146px" DataSourceID="Ds_address" DataTextField="StrName" DataValueField="StrID">
<asp:ListItem Value="null"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddl_EmpID" runat="server" Width="146px" DataSourceID="DS_Employee" DataTextField="LastName" DataValueField="EmpID">
<asp:ListItem Value="null"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txb_date" runat="server" Width="146px"></asp:TextBox>
<asp:CalendarExtender ID="txb_date_CalendarExtender" runat="server" Enabled="True" TargetControlID="txb_date">
</asp:CalendarExtender>
</td>
</tr>
<tr>
<td style="width: 157px"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="width: 157px"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
<br />
<asp:SqlDataSource ID="Ds_address" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsConnectionString %>" SelectCommand="SELECT * FROM [Streets]"></asp:SqlDataSource>
<asp:SqlDataSource ID="DS_Employee" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsConnectionString %>" SelectCommand="SELECT * FROM [Employee]"></asp:SqlDataSource>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</asp:Content>
in other topics people recommend add this
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
but I have it on my page. Any ideas how to fix?
Master page code
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Tickets</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Archivo+Narrow:400,700" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
.Buttons
{
font-family: Tahoma;
font-size: large;
background-color: #999999;
border-bottom-color: #FF0000;
border-style: none none outset none;
}
.Logins
{
font-family: tahoma;
color: #FF0000;
}
.ButtonsInSite
{
font-family: tahoma;
background-color: #C0C0C0;
border-color: #FFFFFF #FFFFFF #FF0000 #FFFFFF;
border-bottom-style: double;
border-radius: 7px;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
box-shadow: 0px 2px 9px #800000;
font-weight: bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="header-wrapper">
<div id="header">
<div id="logo">
<h1>Tickets</h1>
<div style="text-align: right">
<asp:LoginName ID="LoginName2" runat="server" CssClass="Logins" />
|
<asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="Logins" />
</div>
</div>
</div>
</div>
<div id="wrapper">
<!-- end #header -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="sidebar">
<h2>Navigation</h2>
<asp:Button ID="Button1" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite" />
<br />
<asp:Button ID="Button2" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/>
<br />
<asp:Button ID="Button3" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/>
<br />
<asp:Button ID="Button4" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/>
<br />
<asp:Button ID="Button5" runat="server" Text="Admin" Width="118px" CssClass="ButtonsInSite" PostBackUrl="~/Admin/AdmStart.aspx"/>
<br />
</div>
<!-- end #sidebar -->
<div id="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<!-- end #content -->
<div style="clear: both;"> </div>
</div>
</div>
</div>
<!-- end #page -->
</div>
<div id="footer">
<p> © 2013</p>
</div>
<!-- end #footer -->
</form>
</body>
</html>
May be this will help you.
Master page Html
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
Child Page Html
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">Add Scripts here</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
Add Page Content Here</asp:Content>
Add in the master page
<head runat="server">
In a child page header ContentPlaceHolderID just add <head runat="server"></head>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2Header" runat="Server">
<head runat="server">
</head>
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
</asp:Content>
Can you add <head runat="server"> to the master page??
In Master Page add
<head id="Head1" runat="server">
//Other script
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
In child page add
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
//add script for child page
<script>
</script>
</asp:Content>
Try this
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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">
<head runat="server">
in the MASTER PAGE code!
Just substitute <head> for <head id="head1" runat="server">
Masterpage.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'>
</script>
<script src="Chrome.js" type="text/javascript"></script>
</head>
<body>
<form id="Master" runat="server">
<table style="width:987px; margin:auto; height: 86px;">
<tr style="background-color:#FFFFFF">
<td class="style2">
<img src="images/logo.jpg" alt="" width="235" height="73" />
</td>
<td style="vertical-align:middle;"class="style1">
<div style="float:right; width:153px; height: 22px;">
<asp:TextBox ID="TextBox1" runat="server" Height="20px"
style="margin-left: 0px" Width="140px">
</asp:TextBox>
</div>
Forget Password? </span></span>
</td>
<td class="style33">
<div style="float:right; width:157px; height: 20px; margin-right: 1px;">
<asp:TextBox ID="TextBox2" runat="server" Height="20px"
style="margin-left: 0px; margin-top:
Width="147px"></asp:TextBox>
</div>
New User Registration </span>
</td>
<td class="style40">
<div style="height: 67px; width: 81px;">
 <asp:Button ID="btnlogin" runat="server" style="color:White; background-color:#404040;font-family:Verdana;font-size:10pt; height: 29px; margin-top: 12px;" Text="Login" onclick="btnlogin_Click1" /></div>
</td>
</tr>
</table>
</td>
</tr>
<tr style="background-color:#207DA8">
<td class="style39">
</td>
<td class="style39">
</td>
</tr>
<script type="text/javascript">
cssdropdown.startchrome("chromemenu")
</script>
</td>
</tr>
<img alt="" src="images/rgt.jpg" style="width: 471px; height: 247px" />
</td>
</tr>
<tr style="vertical-align=top;background-color=#D4D3D9">
<td style="height:1;">
</td>
</tr>
</tbody>
</table>
</tbody>
</table>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
RegisterPage.aspx
<%# Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" ValidateRequest="false" Inherits="Paragraphreader.Registration" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script src="jquery.validate.js" type="text/javascript"></script>
<script src="jquery.validation.js" type="text/javascript"></script>
<script>
$("#Register").submit(function () {
return $(this).validation();
alert("submitted");
});
</script>
<script>
function validate() {
var a = 0, rdbtn = document.getElementsByName("gender");
for (i = 0; i < rdbtn.length; i++) {
if (rdbtn.item(i).checked == false) {
a++;
}
}
if (a == rdbtn.length) {
document.getElementById("RadioButtonList1").style.border = "2px solid red";
return false;
} else {
document.getElementById("RadioButtonList1").style.border = "";
return true;
}
}
</script>
<link href="Career.css" rel="stylesheet" type="text/css" />
<link href="Chrome.css" rel="stylesheet" type="text/css" />
<link href="Styles.css" rel="stylesheet" type="text/css" />
<form id="Register" runat="server">//A page can have only one form tag
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="FormUpdatePanel" runat="server">
<ContentTemplate>
I am getting error(A page can have only one server side cof while compiling RegisterPage.aspx.In the master page i have a form tag and server side code
In the Register page i have a form tag and server side code.how to avoid this error
Master pages should not contain form tags in general because they are meant to be used only as the base layout of your content page. Remove the form tag from the Master page and the error will go away.
If you want to define a common "Login" section for all your pages (this appears to be your intent), you can instead create a UserControl to do this. You would then define a section inside your Master page to contain this user control making sure that the ContentPlaceHolder of the Login UserControl always ends up enclosed inside the content page's form. That way, when you submit the form, the btnlogin_Click1 click event is triggered.
In conclusion: re-arrange your page in a way that you have one form tag per page, since ASP.NET does not allow having more than one and try to define your form's inside the content pages and not the Master page.
I'm new in ASP.Net and I want to creat a very simple form which bind to a master page but no success. this is my Master Page code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />
</head>
<body>
<form runat=server>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
<body>
<table width=100% border=1 style="background:black" >
<tr>
<td width=20%></td>
<td width=80%><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></td>
<td width=20%></td>
</tr>
</table>
</body>
</asp:ContentPlaceHolder>
</form>
</body>
</html>
and code of my page is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<asp:Content ContentPlaceHolderID=HeadContent runat=server>
</asp:Content>
<asp:Content ID="MainContent" runat=server ContentPlaceHolderID=MainContent >
</asp:Content>
but hte table in the Master Page doesn't appear in the page.Would you please help me to solve this problem?
For starters,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<asp:Content ContentPlaceHolderID=HeadContent runat=server>
</asp:Content>
<asp:Content ID="MainContent" runat=server ContentPlaceHolderID=MainContent >
</asp:Content>
is entirely wrong.
The DOCTYPE should be listed in the master. Secondly:
<asp:Content ID="HContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="MainContent" runat="server" ContentPlaceHolderID="MainContent" >
</asp:Content>
Would more closely match your intent. But one flaw in your style, as it were, and this is strictly a style thing:
<asp:Content ID="HContent" ContentPlaceHolderID="HeadContent" runat="server" >
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server" >
</asp:Content>
Notice how I put runat="server" at the end, on both tags? Always put that at the end, it'll make it easier to make sure you've put it in the right place. Alternately, always put it right before ID
Edit:
<asp:ContentPlaceHolder ID="MainContent" runat="server">
<body>
<table width=100% border=1 style="background:black" >
<tr>
<td width=20%></td>
<td width=80%><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></td>
<td width=20%></td>
</tr>
</table>
</body>
</asp:ContentPlaceHolder>
Where you have this in the master page, the contents of the ContentPlaceHolder won't be shown when a child page implements this section. You'll need to move those outside of the master page ContentPlaceHolder declaration. This concept is very "either or" and there is no room to have an alternate opinion. It was written this way on purpose.
Perhaps you want:
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
<body>
<table width=100% border=1 style="background:black" >
<tr>
<td width=20%></td>
<td width=80%><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></td>
<td width=20%></td>
</tr>
</table>
</body>
Are you specifying the master page in your #Page directive?
For example:
<%# Page Language="C#" MasterPageFile="~/MasterPages/Master1.master" Title="Content Page"%>