I am trying to do an ajax website, but my ajax is not working. I checked my GAC and system.web,extensions dll is available.
Why it is not working .? I am also not getting any errors. I tried many ways.
I wrote the below code to test ajax.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">
</cc1:CalendarExtender>
</div>
</form>
</body>
</html>
JAvascript error that i got
1.Type is not defined
http://localhost:1467/testnew/Default.aspx?_TSM_HiddenField_=ToolkitScriptManager1_HiddenField&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d1.0.20229.20821%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-US%3ac5c982cc-4942-4683-9b48-c2c58277700f%3ae2e86ef9%3aa9a7729d%3a9ea3f0e2%3a9e8e87e9%3a1df13a87%3a4c9865be%3aba594826%3a507fcf1b%3ac7a4182e
You have to make sure ajax 1.0.20229.20821 is registered on your machine before trying to use the controls
You can find it here: http://msdn.microsoft.com/en-us/library/bb861898(v=office.12).aspx
Related
I have a masterpage in ASP.NET Web forms. I created a ContentPlaceHolder between the form tags on the master page. Then I added a web form (named Page.aspx) to the project with the aforementioned masterpage. I added a Content control to the Page.aspx. Then I wanted to add a GridView in Content tags on Page.aspx. But it gives me the following warning: " ASP.NET runtime error: Only Content controls are allowed directly in a content page that contains Content controls.". How can I fix problem? Sorry for my English.
You probably need to wrap them in these tags:
<ContentTemplate></ContentTemplate>
Master Page
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Master.master.cs"
Inherits="Master_Page" %>
<!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">
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<form id="form1" runat="server">
</form>
</html>
Page.aspx
<%# Page Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true"
CodeFile="Page.aspx.cs" Inherits="Faculty_Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Panel ID="Panel2" runat="server" Height="449px">
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
</asp:Panel>
</asp:Content>
Just make a try out of this,It may help
I tried the following code to the Webform.aspx page:
<asp:Button ID="btnShowAssignLecturer" runat="server"
onclick="btnShowAssignLecturer_Click" Text="Assign Lecturer To Room" />
It says: System.Web.HttpException: Control 'ctl00_head_btnShowAssignLecturer' of type 'Button' must be placed inside a form tag with runat=server.
When I do that, I get another error. Not quite sure what to do.
Master page code:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="AllsWellHospital.Front_End.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">
<h1>All Wells Hospital</h1>
<p>
<asp:Label ID="DateDisplay" runat="server"></asp:Label>
</p>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
<link id="Link1" href="/Styles/StyleSheet2.css" runat="server" rel="stylesheet" type="text/css"/>
<style>
body
{
background-color:#d0e4fe;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="topContent">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="WebForm1.aspx" Text="Web form.aspx" Value="Upload SP10"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
</form>
</body>
</html>
Webform.aspx code:
<%# Page Title="" Language="C#" MasterPageFile="~/Front_End/MasterPage.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AllsWellHospital.Front_End.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium"
Text="Course Report"></asp:Label>
<asp:Button ID="btnShowAssignLecturer" runat="server"
onclick="btnShowAssignLecturer_Click" Text="Assign Lecturer To Room" />
</asp:Content>
Your button needs to be within a form tag and currently it isn't. Do you really want to place the button within the head portion of your form? Why not just add another content area for your main content. Try doing something like this:
Master Page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="AllsWellHospital.Front_End.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 id="Head1" runat="server">
<h1>All Wells Hospital</h1>
<p>
<asp:Label ID="DateDisplay" runat="server"></asp:Label>
</p>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
<link id="Link1" href="/Styles/StyleSheet2.css" runat="server" rel="stylesheet" type="text/css"/>
<style>
body
{
background-color:#d0e4fe;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="topContent">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="WebForm1.aspx" Text="Web form.aspx" Value="Upload SP10"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</form>
Your aspx:
<%# Page Title="" Language="C#" MasterPageFile="~/Front_End/MasterPage.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AllsWellHospital.Front_End.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium"
Text="Course Report"></asp:Label>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Button ID="Button1" runat="server"
onclick="btnShowAssignLecturer_Click" Text="Assign Lecturer To Room" />
</asp:Content>
A button must be placed inside of a server managed <form> tag in order for the post to actually do anything in the ASP pipeline.
However, your content place holder Content1 is inside the <head> tag of the master page, where <form> is invalid. You need to rethink your master page so that this content does not live inside of the <head> element, and include a <form runat='server'> surrounding your form.
You may have meant to use the HTML 5 <header> element, which is distintly different than the normal <head> element.
I'm new in asp.net, I am currently in the basic of master.pages.
I am testing how to put an image header to my master page.
Here's my master.master:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="master.master.cs" Inherits="master" %>
<!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:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
And here's the Default.aspx:
<%# Page Title="" Language="C#" MasterPageFile="~/master.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
When I run this, The imageHeader that I put in the master.master, didn't show up.
Any assistance from you guys will be greatly appreciated.
Thanks for all your help!
If you are trying to see the image in all your pages, move out image from ContentPlaceHolder in your MasterPage
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
</asp:ContentPlaceHolder>
TO :
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
I built an internal site for my company with asp.net. I copied the site to the server and tested every page in both firefox and ie and everything looked fine, but i noticed that i forgot to add titles to a couple pages. After adding the titles and copying the updated files to the server, my master page is no longer showing when viewed in ie. All the content is still displayed, but nothing from my master page. Firefox is displaying everything normally. I have tried recopying all the files and restarting the app pool. When i use ie to browse the site from the server everything works fine. Everything works fine when i preview the site locally with vwd2010. I have tried viewing the site from 3 different machines with ie and they all are showing the same thing. Has anyone seen anything like this before?
MasterPage
<%# 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>
<link rel="Stylesheet" type="text/css" href="styles/Styles.css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="page">
<div class="header">
<div class="title">
<h1>
register support
</h1>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="howto.aspx" Text="Common Problems"/>
<asp:MenuItem NavigateUrl="search.aspx" Text="Search"/>
<asp:MenuItem NavigateUrl="~/incidents.aspx" Text="Incidents" />
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server" />
</div>
</div>
<div class="bottomlinks">
[administrators]
</div>
</div>
</form>
</body>
</html>
Content Page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<div>
<asp:PlaceHolder ID="place1" runat="server" />
<asp:PlaceHolder ID="place2" runat="server" />
</div>
</asp:Content>
I am working with master pages and I would like to see what the top of your .aspx web page looks like.. for example it should look something like this
<%# Page Title="Student Registration" Language="C#" MasterPageFile="~/Site.Master"
AutoEventWireup="true" CodeBehind="StudentInfo.aspx.cs" Inherits="MRC_IDSWeb.Pages.StudentInfo" MaintainScrollPositionOnPostback="true" %>
Set the Page Title in the page Header Separately.. not in the html like you would in a .aspx page that does not utilize MasterPages hope this makes sense to you
I am currently referencing this website for AD role management.
The C# code is working fine, but when I pasted the code inside my webpage along with the masterpage, the page gave me an error which says:
Content controls have to be top-level controls in a content page or a nested master page that references a master page.
May I know how should I set my masterpage in this case?
.ASPX page without masterpage:
<%# Page Language="C#" %>
<%# Import Namespace="System.Web.Security" %>
<%# Import Namespace="System.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
string[] rolesArray;
MembershipUserCollection users;
string[] usersInRole;
public void Page_Load()
{
....
}
public void AddUsers_OnClick(object sender, EventArgs args)
{
....
}
public void UsersInRoleGrid_RemoveFromRole(object sender, GridViewCommandEventArgs args)
{
....
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Role Membership</title>
</head>
<body>
<form runat="server" id="PageForm">
<font face="helvetica" size="6" color="#455c75"><strong>Role Membership</strong></font><font face="helvetica" size="5" color="#455c75"><strong> Management</strong></font>
<br /><asp:Label ID="Msg" ForeColor="maroon" runat="server" /><br />
<table cellpadding="3" border="0">
...
</table>
</form>
Masterpage:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MainPage.master.cs" Inherits="MainPage" %>
<!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 id="Head1" runat="server">
<title>SOD</title>
<link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
...
</body>
</html>
EDIT:
I tried inserting MasterPageFile="~/MainPage.master" into the first tag, which start my .aspx page with <%# Page Language="C#" MasterPageFile="~/MainPage.master"%>, giving me the error mentioned above.
The Masterpage contains HTML code and content areas. The pages that use the masterpage must, MUST, have all code in an <asp:Content> tag. You can't have any sort of code outside of the Content tag.
You need to place your code inside an <asp:Content ID="content1" ContentPlaceHolderID="Content_pageBody" Runat="Server"></content> tag. This tag should map to your master page, where ContentPlaceHolderID = the place holder name in your master page