java脚本不适用于母版页 [英] java script not work with master page

查看:55
本文介绍了java脚本不适用于母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个母版页面,其中包含样式为div类的java脚本:

 <   script     type   =  text / javascript >  
$(文件).ready(function(){

var options = {
styleClass:selectDark,
jScrollPane:1
}

$(。mySelect)。styleSelect(options);

});
< / script >







下一步我还有一个页面:

已下拉:

 <   asp:DropDownList     ID   = < span class =code-keyword> DropDownList2      CssClass   =  mySelect    runat   =  server >  
< asp:列表项目 > 1 < / asp :ListItem >
< asp:ListItem > 2 < / asp:ListItem >
< / asp:DropDownList >





但是这个mySelect类不适用于此,



1.如果我不使用母版页,它只能有一个简单的页面,它可以正常工作: br />
2.如果我使用html drop down,它可以与母版页一起工作:

 < ;  选择    id   =  Select1    class   =  mySelect >  
< 选项 > 1 < / option >

< 选项 > 2 < / option >
< / select >







s o我能做什么,我也把这个java脚本放在内容页面或母版页中,但是当使用母版页并使用asp.net控件时它不起作用,

有人说控件id用主页更改,

但是这里是一个div类,以及这个div类id如何改变。

plz帮我

解决方案

(document).ready(function(){

var options = {
styleClass:selectDark,
jScrollPane:1
}

( mySelect。)styleSelect(选项)。;

});
< / script >







下一步我还有一个页面:

已下拉:

 <   asp:DropDownList     ID   = < span class =code-keyword> DropDownList2      CssClass   =  mySelect    runat   =  server >  
< asp:列表项目 > 1 < / asp :ListItem >
< asp:ListItem > 2 < / asp:ListItem >
< / asp:DropDownList >





但是这个mySelect类不适用于此,



1.如果我不使用母版页,它只能有一个简单的页面,它可以正常工作: br />
2.如果我使用html drop down,它可以与母版页一起工作:

 < ;  选择    id   =  Select1    class   =  mySelect >  
< 选项 > 1 < / option >

< 选项 > 2 < / option >
< / select >







s o我能做什么,我也把这个java脚本放在内容页面或母版页中,但是当使用母版页并使用asp.net控件时它不起作用,

有人说控件id更改为母版页,

但这里是一个div类,以及这个div类ID是如何更改的。

plz帮帮我


仅在您的控件所在的同一页面中使用您的javascript ...


i have a master page which have java script for style a div class:

<script type="text/javascript">
    $(document).ready(function () {

        var options = {
            styleClass: "selectDark",
            jScrollPane: 1
        }

        $(".mySelect").styleSelect(options);

    });
</script>




in next step i also have a page:
which have drop down:

<asp:DropDownList ID="DropDownList2"  CssClass="mySelect" runat="server">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
    </asp:DropDownList>



but this "mySelect" class not work with this,

1. it work well if i not use master page, and only have a simple page:
2. it work with master page if i use html drop down like this:

<select id="Select1" class="mySelect">
       <option>1</option>

         <option>2</option>
   </select>




so what can i do, i also put this java script in content page, or master page but it not work when master page is use and asp.net control is used,
some one says that control id is changed with master page,
but here is a div class, and how this div class id changed.
plz help me

解决方案

(document).ready(function () { var options = { styleClass: "selectDark", jScrollPane: 1 }


(".mySelect").styleSelect(options); }); </script>




in next step i also have a page:
which have drop down:

<asp:DropDownList ID="DropDownList2"  CssClass="mySelect" runat="server">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
    </asp:DropDownList>



but this "mySelect" class not work with this,

1. it work well if i not use master page, and only have a simple page:
2. it work with master page if i use html drop down like this:

<select id="Select1" class="mySelect">
       <option>1</option>

         <option>2</option>
   </select>




so what can i do, i also put this java script in content page, or master page but it not work when master page is use and asp.net control is used,
some one says that control id is changed with master page,
but here is a div class, and how this div class id changed.
plz help me


use your javascript in same page only where your control is...


这篇关于java脚本不适用于母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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