MasterPage和Javascript [英] MasterPage and Javascript

查看:121
本文介绍了MasterPage和Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问具有母版页引用的aspx页面内的一些javascript代码。我在头部创建了一个ContentPlaceHolder来保存javascript引用。



I am trying to access some javascript code inside an aspx page which has a master page reference. I created a ContentPlaceHolder in the head to hold the javascript references.

<asp:ContentPlaceHolder ID="HeadContentPlaceHolder" runat="server">

        <title>Sign Matrix</title>
        <link rel="Stylesheet" href="StyleSheet.css" type="text/css" />

    <script src="Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui.js" type="text/javascript"></script>
        <link href="Styles/jquery-ui.css" rel="stylesheet" type="text/css" />
    </asp:ContentPlaceHolder>




我的aspx页面内的
代码如下





inside of my aspx page the code is as follows

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContentPlaceHolder" runat="server">



       <script language="javascript" type="text/javascript">
        // <!CDATA[
        function body_onLoad() {
            var radioButtons = document.getElementsByName("rblAd");
            if (radioButtons.length != 0) {
                if (document.forms['form1'].hfLevelTypeID.value == "4") {
                    radioButtons[3].style.visibility = 'hidden';
                }
                var which = 2;
                if (document.forms['form1'].hfAhead.value != "")
                    which = parseInt(document.forms['form1'].hfAhead.value, 10) + 2;
                if (which >= 0 && which <= 3)
                    radioButtons[which].checked = true;
            }
        }

        function setSelectedIndex(s, v) {
            for (var i = 0; i < s.options.length; i++) {
                if (s.options[i].value == v) {
                    s.options[i].selected = true;
                    return;
                }
            }
        }
        function rblAd_onClick(e) {
            if (!e)
                e = event;
            var obj = e.target || e.srcElement;
            document.forms['form1'].hfAhead.value = obj.value;
            if (document.forms['form1'].hfLevelTypeID.value != "4") {
            setSelectedIndex(document.forms['form1'].ddlWeek, document.forms['form1'].hfAhead.value);
            }
            //document.forms['form1'].tbSearch01.value = "";
            //document.forms['form1'].tbSearch02.value = "";
            //document.forms['form1'].tbSearch03.value = "";
            document.forms['form1'].action = 'listSignBeta.aspx?hfAction=' + document.forms['form1'].hfAction.value + '&hfDepartment=' + document.forms['form1'].hfDepartment.value + '&hfTier=' + document.forms['form1'].hfTier.value + '&hfSignTypeID=' + document.forms['form1'].hfSignTypeID.value + '&hfAhead=' + document.forms['form1'].hfAhead.value; //  + '&hfS1=' + encodeURI(document.forms['form1'].tbSearch01.value) + '&hfS2=' + encodeURI(document.forms['form1'].tbSearch02.value) + '&hfS3=' + encodeURI(document.forms['form1'].tbSearch03.value);
            document.forms['form1'].enctype = "application/x-www-form-urlencoded"; //"application/x-www-html-urlencoded";  //"text/plain"; //
            document.forms['form1'].submit();
        }
        function btnEnd_onclick() {
            var confirm = window.confirm("Are you sure you want to end Sign Share?")
            if (confirm) {
                document.forms['form1'].action = 'end.aspx';
                document.forms['form1'].enctype = "application/x-www-form-urlencoded"; //"text/plain";
                document.forms['form1'].submit();
                return true;
            }
            else
                return false
        }

        function getRadioCheckValue(cbIncludeBatch) {
            var oRadio = document.forms['form1'].elements[cbIncludeBatch];
            for (var i = 0; i < oRadio.length; i++) {
                if (oRadio[i].checked) {
                    return oRadio[i].value;
                }
            }
            return '';
        }
        function cbIncludeBatch_onclick(cbIncludeBatch)
        {
            var count = document.getElementsByName("cbIncludeBatch");
            // var checkbox_val = cbIncludeBatch.value;
            //var check_val = document.forms['form1'].elements[cbIncludeBatch];
            for (var i = 0; i < count.length; i++)
             {
                if (count[i].checked)
                {
                    var agree = window.confirm("This request involves a large number of signs and will take a few moments. Would you like to proceed?");
                    if (agree) {
                        //                        if (document.forms['form1'].hfIncludeBatch.value == true)
                        //                        {

                        document.forms['form1'].action = 'listSignBeta.aspx?hfAction=' + document.forms['form1'].hfAction.value + '&hfDepartment=' + document.forms['form1'].hfDepartment.value + '&hfTier=' + document.forms['form1'].hfTier.value + '&hfSignTypeID=' + document.forms['form1'].hfSignTypeID.value + '&hfAhead=' + document.forms['form1'].hfAhead.value + '&hfIncludeBatch=true'; //  + '&hfS1=' + encodeURI(document.forms['form1'].tbSearch01.value) + '&hfS2=' + encodeURI(document.forms['form1'].tbSearch02.value) + '&hfS3=' + encodeURI(document.forms['form1'].tbSearch03.value);
                        document.forms['form1'].enctype = "application/x-www-form-urlencoded"; //"application/x-www-html-urlencoded";  //"text/plain"; //
                        document.forms['form1'].submit();
                        return true;
                    }
                    else

                            count[i].checked = false;
                            return false
                }
                    else
                        document.forms['form1'].action = 'listSignBeta.aspx?hfAction=' + document.forms['form1'].hfAction.value + '&hfDepartment=' + document.forms['form1'].hfDepartment.value + '&hfTier=' + document.forms['form1'].hfTier.value + '&hfSignTypeID=' + document.forms['form1'].hfSignTypeID.value + '&hfAhead=' + document.forms['form1'].hfAhead.value + '&hfIncludeBatch=false'; //  + '&hfS1=' + encodeURI(document.forms['form1'].tbSearch01.value) + '&hfS2=' + encodeURI(document.forms['form1'].tbSearch02.value) + '&hfS3=' + encodeURI(document.forms['form1'].tbSearch03.value);
                        document.forms['form1'].enctype = "application/x-www-form-urlencoded"; //"application/x-www-html-urlencoded";  //"text/plain"; //
                        document.forms['form1'].submit();
                        count[i].checked = false;
                        return false
            }
        }

        function btnEdit_onClick(id) {
            var sep1 = id.indexOf("_");
            var sep2 = id.indexOf("_", sep1 + 1);
            var sep3 = id.indexOf("_", sep2 + 1);
            var sep4 = id.indexOf("_", sep3 + 1);
            document.forms['form1'].hfSignID.value = id.substring(0, sep1);
            document.forms['form1'].hfSignLevelID.value = id.substring(sep1 + 1, sep2);
            document.forms['form1'].hfStampID.value = id.substring(sep2 + 1, sep3);
            document.forms['form1'].hfSignLevelTypeID.value = id.substring(sep3 + 1, sep4);
            document.forms['form1'].hfSizeID.value = id.substring(sep4 + 1);
            document.forms['form1'].action = 'oneSign.aspx?hfSignID=' + document.forms['form1'].hfSignID.value + '&hfSignLevelID=' + document.forms['form1'].hfSignLevelID.value + '&hfStampID=' + document.forms['form1'].hfStampID.value + '&hfSignLevelTypeID=' + document.forms['form1'].hfSignLevelTypeID.value + '&hfSizeID=' + document.forms['form1'].hfSizeID.value + '&hfLevelID=' + document.forms['form1'].hfLevelID.value + '&hfLevelTypeID=' + document.forms['form1'].hfLevelTypeID.value + '&hfLevelUserInfoID=' + document.forms['form1'].hfLevelUserInfoID.value + '&hfAction=' + document.forms['form1'].hfAction.value + '&hfDepartment=' + document.forms['form1'].hfDepartment.value + '&hfTier=' + document.forms['form1'].hfTier.value + '&hfSignTypeID=' + document.forms['form1'].hfSignTypeID.value + '&hfAhead=' + document.forms['form1'].hfAhead.value;   //  + '&hfS1=' + encodeURI(document.forms['form1'].tbSearch01.value) + '&hfS2=' + encodeURI(document.forms['form1'].tbSearch02.value) + '&hfS3=' + encodeURI(document.forms['form1'].tbSearch03.value);
            document.forms['form1'].enctype = "application/x-www-form-urlencoded"; //"application/x-www-html-urlencoded";  //"text/plain"; //
            document.forms['form1'].submit();
        }
        function printWindow() {
            window.print();
        }

        $(window).bind('load', function () {
            var headerChk = $(".cssPrintAll input");
            var itemChk = $(".cssPrintItem input");
            headerChk.bind("click", function () {
                itemChk.each(function () { this.checked = headerChk[0].checked; })
            }
                );
            itemChk.bind("click", function () { if ($(this).checked == false) headerChk[0].checked = false; });

            //delete all
            var delheaderChk = $(".cssDeleteAll input");
            var delitemChk = $(".cssDeleteItem input");
            delheaderChk.bind("click", function () {
                delitemChk.each(function () { this.checked = delheaderChk[0].checked; })
            }
                );
            delitemChk.bind("click", function () { if ($(this).checked == false) delheaderChk[0].checked = false; });

            //select all
            var selheaderChk = $(".cssSelectAll input");
            var selitemChk = $(".cssSelectItem input");
            selheaderChk.bind("click", function () {
                selitemChk.each(function () { this.checked = selheaderChk[0].checked; })
            }
                );
            selitemChk.bind("click", function () { if ($(this).checked == false) selheaderChk[0].checked = false; });
        });
        // ]]>
</script>
  </asp:Content>







之后,我有另一个内容占位符,其中包含需要javascript的按钮。请告知




after that i have another content placeholder that holds the buttons that require the javascript. Please advise

推荐答案

(窗口).bind(' load',function(){
var headerChk =
(window).bind('load', function () { var headerChk =


。cssPrintAll input);
var itemChk =
(".cssPrintAll input"); var itemChk =


。cssPrintItem input);
headerChk.bind( click,function(){
itemChk.each(function (){已检查 = headerChk [ 0 ]。 checked ;})
}
);
itemChk.bind( 点击,function(){ if
(".cssPrintItem input"); headerChk.bind("click", function () { itemChk.each(function () { this.checked = headerChk[0].checked; }) } ); itemChk.bind("click", function () { if (


这篇关于MasterPage和Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆