Click here to Skip to main content
14,767,302 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
<%@ Page Language="C#" MasterPageFile="~/UserPage.master" AutoEventWireup="true" CodeFile="Signup.aspx.cs" Inherits="Signup" %>


<html xmlns="http://www.w3.org/1999/xhtml"/>
<head  runat="server">
<script type="text/javascript" language ="javascript">
function getSelectValue(sel) {

    var val;
    // only if there is a selected item
    if (sel.selectedIndex > -1) {
        // get the value from the select element
        val=sel.options[sel.selectedIndex].value;
       // alert(val);
    }

    return val;
}


        function ddlChange(DropDownID,TextBoxID)
        {
            var c=document.getElementById(DropDownID);
            var div=document.getElementById(TextBoxID);
            if(getSelectValue(c)=='108')
            {
                div.value='';
                div.style.visibility="visible";
                if (div.Validators&&div.Validators.length) {
                   for (var i=0; i<div.Validators.length; i++)
                       ValidatorEnable(div.Validators[i], true)
                }
            }
            else
            {
                div.value='108';
                div.style.visibility="hidden";
                if (div.Validators&&div.Validators.length) {
                   for (var i=0; i<div.Validators.length; i++)
                       ValidatorEnable(div.Validators[i], false)
                }
            }
        }

</script>
</head>
<asp:Content ID="Content1" runat="server"
    contentplaceholderid="ContentPlaceHolder1"/>


</html>


Hi Sir,
I am facing this error, i.e: Only Content controls are allowed directly in a content page that contains content controls.



Thanks.

[edit]"Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 19-Apr-11 21:16pm
v3
Comments
SURBHI TYAGI 20-Apr-11 2:05am
   
ok.but where should i put this script to remove this error?

1 solution

You cannot have <head> and such tags in a page which uses CSS (they are already in the stylesheet). Cut your page down (this is a cut down sample from one of mine):
<![CDATA[<%@ Page Language="C#" MasterPageFile="~/Resources/Masters/OverAll.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>
<![CDATA[<%@ MasterType VirtualPath="~/Resources/Masters/OverAll.master" %>
<asp:content id="ContentHead" contentplaceholderid="pageHead" runat="Server" xmlns:asp="#unknown">
    <!--  Empty - emergencies only, at top of page.  -->

<asp:content id="ContentBody" contentplaceholderid="cphBody" runat="Server" xmlns:asp="#unknown">
    <script type="text/javascript" language="javascript">
        function getSelectValue(sel) {
            var val;
            // only if there is a selected item
            if (sel.selectedIndex > -1) {
                // get the value from the select element
                val = sel.options[sel.selectedIndex].value;
                // alert(val);
            }
            return val;
        }

        function ddlChange(DropDownID, TextBoxID) {
            var c = document.getElementById(DropDownID);
            var div = document.getElementById(TextBoxID);
            if (getSelectValue(c) == '108') {
                div.value = '';
                div.style.visibility = "visible";
                if (div.Validators && div.Validators.length) {
                    for (var i = 0; i < div.Validators.length; i++)
                        ValidatorEnable(div.Validators[i], true)
                }
            }
            else {
                div.value = '108';
                div.style.visibility = "hidden";
                if (div.Validators && div.Validators.length) {
                    for (var i = 0; i < div.Validators.length; i++)
                        ValidatorEnable(div.Validators[i], false)
                }
            }
        }
 
    </script>


[edit]Script sample shown in content block - OriginalGriff[/edit]
[edit2]"lang" of pre block set to htm to improve display - OriginalGriff[/edit2]
   
v3
Comments
SURBHI TYAGI 20-Apr-11 2:14am
   
sir i wanna use the above javascript and just ignore the head tag...i wanna ask that where should i put this script by which my code can work.
OriginalGriff 20-Apr-11 2:48am
   
Answer Updated

Try either inserting the script section in the relevant content block, or in the Master Page...
SURBHI TYAGI 20-Apr-11 4:24am
   
okss thanks sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900