Saturday, March 24, 2012

Ajax and MasterPage issues (tags like scriptManager and html - not recognized)

I am having problem with AJAX Toolkit and MasterPages.

When I create a new Content Page and use html tags or ahax scriptManager I recevied lots of errors.

I cannot seem to get this resolved.

Here find below example I am working on - none of the html or scriptManager stuff for ajax is being recongnised.

Please assist.

File Sample

------------

<%@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="laz.aspx.cs"Inherits="laz"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

</asp:Content>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<scriptrunat="server">

protectedvoid btnRefresh_Click(object sender,EventArgs e)

{

}

</script>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Untitled Page</title>

<linkhref="StyleSheet.css"rel="stylesheet"type="text/css"/>

</head>

<body>

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<asp:PanelID="Panel1"runat="server"CssClass="modalPopup"Height="50px"Width="235px"style="display:none"DefaultButton="btnOk">

<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<%=DateTime.Now.ToString() %>

<divstyle="display:none">

<asp:ButtonID="btnRefresh"runat="server"Text="Refresh"OnClick="btnRefresh_Click"/>

</div>

</ContentTemplate>

</asp:UpdatePanel>

<asp:ButtonID="btnCancel"runat="server"Text="Cancel"/>

<asp:ButtonID="btnOk"runat="server"Text=" OK "/>

</asp:Panel>

<asp:ButtonID="Button2"runat="server"Text="Button"Enabled="false"style="display:none"/>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="Button2"PopupControlID="Panel1"CancelControlID="btnCancel"DropShadow="true"BackgroundCssClass="modalBackground">

</ajaxToolkit:ModalPopupExtender>

<inputid="Button3"type="button"value="Click Me"onclick="showModalPopup()"/>

<scripttype="text/javascript"language="javascript">

function showModalPopup(){

$get("<%=btnRefresh.ClientID %>").click();

$find("<%= this.ModalPopupExtender1.ClientID %>").show();

}

</script>

</form>

</body>

</html>

...........?

why are all the tags outside the <asp:Content? Aren't they suppose to be inside?


Honestly is does not matter if the content is inside the ASP tag or not. I was testing the contents outside. Here find the same results with ASP tag and content inside.

With the below I receive 7 errors

1. Only content controls allowed directly in content page. LINE 16

2. Validation XHTML 1.0 Element body cannot be in nested within <div> - I do not have div tag in ths aspx page but maybe it comes from the masterpage? LINE 14

3. Element Script Manager not a knwon element LINE 16

4. Element UpdatePanel unknown element LINE 19

5. Validation Element contenttemplate is not supported LINE 20

6. Element Button is not a known element Line 23

<%@.PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="laz.aspx.cs"Inherits="laz"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<scriptrunat="server">

protectedvoid btnRefresh_Click(object sender,EventArgs e)

{

}

</script>

<body> LINE 14

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server"> LINE 16

</asp:ScriptManager>

<asp:PanelID="Panel1"runat="server"CssClass="modalPopup"Height="50px"Width="235px"style="display:none"DefaultButton="btnOk">

<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional"> LINE 19

<ContentTemplate> LINE 20

<%=DateTime.Now.ToString() %>

<divstyle="display:none">

<asp:ButtonID="btnRefresh"runat="server"Text="Refresh"OnClick="btnRefresh_Click"/> LINE 23

</div>

</ContentTemplate>

</asp:UpdatePanel>

<asp:ButtonID="btnCancel"runat="server"Text="Cancel"/>

<asp:ButtonID="btnOk"runat="server"Text=" OK "/>

</asp:Panel>

<asp:ButtonID="Button2"runat="server"Text="Button"Enabled="false"style="display:none"/>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="Button2"PopupControlID="Panel1"CancelControlID="btnCancel"DropShadow="true"BackgroundCssClass="modalBackground">

</ajaxToolkit:ModalPopupExtender>

<inputid="Button3"type="button"value="Click Me"onclick="showModalPopup()"/>

<scripttype="text/javascript"language="javascript">

function showModalPopup(){

$get("<%=btnRefresh.ClientID %>").click();

$find("<%= this.ModalPopupExtender1.ClientID %>").show();

}

</script>

</form>

</body>

</asp:Content>


from what you have here is that you have a <body> and <form> tags; those normally are already declared in the MasterPage. Check it again.


Yes I added the tags in Master page and removed from content page.

Also I added a masterpage.master.vb file and applied the imports which solved the issue with the scriptmanager.

No comments:

Post a Comment