| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 718 人关注过本帖
标题:请大家帮我看看:有关javascript的缺少对象提示
取消只看楼主 加入收藏
ibiws
Rank: 1
来 自:哈尔滨
等 级:新手上路
帖 子:55
专家分:0
注 册:2007-7-12
收藏
 问题点数:0 回复次数:0 
请大家帮我看看:有关javascript的缺少对象提示
我新建一个项目,前台代码中有form标记,那么以下的javascript运行没有问题,可是我放到我的程序中(页面a.aspx),由于我在a.aspx中用了模板页,a.aspx中没有form标记,该段代码总提示“缺少对象”!怎样改也不行!
大家帮我看看我应怎样写这句话!
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsStartupScriptRegistered("lb_Trust_Major"))
        {
            ListBox_DblClick("lb_Trust_Major", Page, lb_Trust_Major, "lb_Trust_Major", "lb_NotTrust_Major");
        }
        if (!Page.IsStartupScriptRegistered("lb_NotTrust_Major"))
        {
            ListBox_DblClick("lb_NotTrust_Major", Page, lb_NotTrust_Major, "lb_NotTrust_Major", "lb_Trust_Major");
        }
    }

    public void ListBox_DblClick(string Key, Page page, System.Web.UI.WebControls.WebControl webcontrol, string RemoveListBox, string AddListBox)
    {
        RemoveListBox = "document.getElementById('" + RemoveListBox+"')";
        AddListBox = "document.getElementById('" + AddListBox + "')";
        string mflistboxjs = "<script type=text/javascript> function change(RemoveListBox,AddListBox)";
        mflistboxjs += "{";
        mflistboxjs += "var addOption=document.createElement('option'); \n";
        mflistboxjs += "var index1; \n";
        mflistboxjs += "if(RemoveListBox.length==0)return(false);\n";
        mflistboxjs += "index1=RemoveListBox.selectedIndex; \n ";
        mflistboxjs += "if(index1<0)return(false);\n";
        mflistboxjs += "addOption.text=RemoveListBox.options(index1).text; \n";
        mflistboxjs += "addOption.value=RemoveListBox.value; \n";
        mflistboxjs += "AddListBox.add(addOption); \n";
        mflistboxjs += "RemoveListBox.remove (index1) \n";
        mflistboxjs += "}";
        mflistboxjs += "</script>";
        page.RegisterStartupScript(Key, mflistboxjs);
        webcontrol.Attributes.Add("onDblClick", "change(" + RemoveListBox + "," + AddListBox + ");");
    }
=========================================
<%@ Page Language="C#" MasterPageFile="~/ProductManagement/ProductManLib.master" AutoEventWireup="true" CodeFile="MajorTrustMan.aspx.cs" Inherits="SystemManagement_MajorTrustMan" Title="专业信任关系管理" Theme="Buton" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
   
    <table border="0" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE: collapse" bordercolor="#111111"
            width="100%" height="1">
        <tr height="30">
        <td width="3%" bgcolor="#c0d9e6" class="GbText" background="../../Images/treetopbg.jpg"><font color="#006699" size="3"><img src="../pic/moduleheaher.gif" width="16" height="16"></font></td>
        <td bgcolor="#c0d9e6" class="GbText" background="~/pic/treetopbg.jpg"><b>专业信任关系管理</b></td>
        </tr>
    </table>
    <TABLE class="GbText" style="BORDER-COLLAPSE: collapse; width: 103%; height: 79%;" borderColor="#93bee2" cellSpacing="0" <%--background="../pic/left_right_massimport.jpg"--%>
                cellPadding="0" border="0">
            <tr >
                <td style="height :35px; text-align: center;" colspan="3">
                </td>
            </tr>
            <tr>
                <td  colspan="3" style="height: 20px; text-align: center">
                    ? ? ? ? ? ? ? ? ? ??
                    <asp:Label ID="Label1" runat="server" Text="  主专业: "></asp:Label>
                    <asp:DropDownList ID="ddl_Main_Major"  runat="server" Width="75px" AutoPostBack ="true" OnSelectedIndexChanged="ddl_Main_Major_SelectedIndexChanged" >
                    </asp:DropDownList></td>
            </tr>
        <tr>
            <td colspan="3" style="height: 10px; text-align: center">
            </td>
        </tr>
            <tr>
                <td align ="right" style=" height :10px; width: 46%;">
                    已信任专业</td>
                <td width ="8%" align ="center" style="height :10px">
                    </td>
                <td align ="left" style="width: 147px; height: 10px">
                    备选信任专业</td>
            </tr>
            <tr>
                <td align ="right" style="height :267px; width: 46%;">
                    <asp:Panel ID="Panel1" runat="server" Height="250px" Width="100%">
                        &nbsp;<asp:ListBox ID="lb_Trust_Major" runat="server" Height="250px" Width="160px" SelectionMode ="Multiple" >
                        </asp:ListBox
></asp:Panel>
                </td>
                <td width ="8%" align ="center"  style="height :267px">
                    <asp:ImageMap ID="im_Trust_Major" runat="server"  ImageUrl="~/pic/箭头.gif" OnClick="im_Trust_Major_Click">
               <asp:RectangleHotSpot AlternateText="加入" Bottom="35" HotSpotMode="PostBack" PostBackValue ="ToRight" Right="35" />
               <asp:RectangleHotSpot AlternateText="从列表中删除" Bottom="70" HotSpotMode="PostBack" PostBackValue ="ToLeft" Right="35"  Top="35" />
               <asp:RectangleHotSpot AlternateText="全部加入" Bottom="105" HotSpotMode="PostBack" PostBackValue ="All_ToRight" Right="35"  Top="70" />
               <asp:RectangleHotSpot AlternateText="全部从列表中删除" Bottom="140" HotSpotMode="PostBack"  PostBackValue ="All_ToLeft"  Right="35" Top="105" />
               </asp:ImageMap></td>
                <td align ="center" style="height: 267px; width: 147px;">
                    
                    <asp:ListBox ID="lb_NotTrust_Major" runat="server" Height="250px" Width="182px" SelectionMode ="Multiple" >
                    </asp:ListBox></td><
td style="width: 46px; height: 267px;">           ? ? ?
                    </td>
              <TD align="left" style="width: 37px; height: 267px">
   
我觉得现在主要是 RemoveListBox = "document.getElementById('" + RemoveListBox+"')";
               AddListBox = "document.getElementById('" + AddListBox + "')";   的写法不对。
请大家帮出出主意!!!谢谢~~            ??

[[italic] 本帖最后由 ibiws 于 2007-12-11 23:09 编辑 [/italic]]
搜索更多相关主题的帖子: javascript Major Trust 对象 
2007-12-11 23:04
快速回复:请大家帮我看看:有关javascript的缺少对象提示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027034 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved