在gridview的模版列中放置menu
GridView1_RowDataBound中menu绑定动态菜单,
还有一个页面在gridview的模版列中放置linkbutton
GridView1_RowDataBound中绑定linkbutton连接指向,
在本地运行没有问题,上传服务器后,
鼠标悬停后动态菜单不显示,
linkbutton也不跳转,
左下角iE状态栏显示脚本错误。
大家帮我看看是哪不对,linkbutton
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                                CellPadding="1" DataKeyNames="id" Font-Size="12px" PageSize="15" Width="100%" OnRowDataBound="GridView1_RowDataBound">
                                <EmptyDataTemplate>
                                    没有与此关联的数据
                                </EmptyDataTemplate>
                                <Columns>
                                    <asp:TemplateField HeaderText="操作">
                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px" />
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server">查看</asp:LinkButton>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                    </asp:TemplateField>
                                </Columns>
                                <PagerSettings Visible="False" />
                                <HeaderStyle BackColor="DimGray" ForeColor="White" Height="15px" HorizontalAlign="Center" />
                                <AlternatingRowStyle BackColor="WhiteSmoke" />
                                <RowStyle Height="18px" HorizontalAlign="Center" />
                            </asp:GridView>linkbutton绑定连接
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //查看短信消息
            LinkButton link=new LinkButton();
            link= (LinkButton)e.Row.FindControl("LinkButton1");
            link.PostBackUrl = "messContent.aspx?id=" + this.GridView1.DataKeys[e.Row.RowIndex].Value.ToString()+"&itemid="+Request.QueryString["itemid"];
         }
    }
menu<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CellPadding="1" DataKeyNames="id" Width="100%">
            <PagerSettings Visible="False" />
            <Columns>
                <asp:TemplateField HeaderText="操作">
                    <ItemStyle Height="25px" HorizontalAlign="Center" VerticalAlign="Middle" Width="25px" />
                    <ItemTemplate>
                       <asp:Menu ID="Menu1" runat="server" DynamicHorizontalOffset="1" Font-Names="宋体" Font-Size="12px"
                            ForeColor="#284E98" Height="1px" StaticEnableDefaultPopOutImage="False" StaticSubMenuIndent="10px"
                            Width="100%">
                            <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                            <DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
                            <DynamicMenuStyle BackColor="#B5C7DE" />
                            <StaticSelectedStyle BackColor="#507CD1" />
                            <DynamicSelectedStyle BackColor="#507CD1" />
                            <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                            <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
                        </asp:Menu>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="#F3FAFF" Height="10px" />
        </asp:GridView>  Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If Not (e.Row.RowType = DataControlRowType.Footer Or e.Row.RowType = DataControlRowType.Header) Then
            Dim menu1 As Menu
            menu1 = e.Row.FindControl("Menu1")
            menu1.Items.Clear()
            Dim item0 As New MenuItem
            item0.ImageUrl = "../images/edit.gif"
            item0.Text = ""
            item0.Value = ""
            Dim item1 As MenuItem
            item1 = New MenuItem
            item1.Text = "修改"
            item1.Value = GridView1.DataKeys(e.Row.RowIndex).Value & "0"
            item1.NavigateUrl = "javascript:window.open('pageNewEdit.aspx?up=role1&action=mody&id=" & GridView1.DataKeys(e.Row.RowIndex).Value & "&tablename=role1','" & "_self');"
            item0.ChildItems.Add(item1)            item1 = New MenuItem
            item1.Text = "权限"
            item1.Value = GridView1.DataKeys(e.Row.RowIndex).Value & "3"
            item1.NavigateUrl = "javascript:window.open('limits.aspx?tablename=role1&id=" & GridView1.DataKeys(e.Row.RowIndex).Value & "','" & "_self');"
            item0.ChildItems.Add(item1)            item1 = New MenuItem
            item1.Text = "删除"
            item1.Value = GridView1.DataKeys(e.Row.RowIndex).Value & "1"
            item1.NavigateUrl = "javascript:deleteTrue('role1','" & GridView1.DataKeys(e.Row.RowIndex).Value & "')"
            item0.ChildItems.Add(item1)
            menu1.Items.Add(item0)
        End If
    End Sub

解决方案 »

  1.   

    我看了看linkbutton页报的是webFrom_PostbackOptions 未定义menu页面包的是缺少对象
      

  2.   

    在ASP代码文件中引用VS2005字都生成的System_Web_Resources.js 文件就可以了,此文件应该在网站根目录下
      

  3.   

    landySS() ( ) 信誉:100    Blog  2006-11-27 8:47:05  得分: 0  
    在ASP代码文件中引用VS2005字都生成的System_Web_Resources.js 文件就可以了,此文件应该在网站根目录下
    -----------------------------------------
    解决了,谢谢
    也谢谢
    yan63(silence like a cancer grows)