zoukankan      html  css  js  c++  java
  • GridView中HyperLinkField的链接使用JavaScript问题

    本来写好的程序,突然增加需求说要点链接以后刷新父页面并弹出窗口,弹出可以直接用Target属性,在网上查了查,DataNavigateUrlFields并不支持JavaScript,在别人博客上还找到了后台绑定数据的方法,感觉改动太大,后来在一个老外的博客上找到了个方法,使用了GridView的TemplateField。

    原代码:<asp:HyperLinkField DataNavigateUrlFields="ItemUrl" DataTextField="ItemName" HeaderText="标 题"
                        Target="_blank">
                        <ItemStyle HorizontalAlign="Left" Width="60%" />

                    </asp:HyperLinkField>

    修改后代码: <asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="标 题" SortExpression="标 题">
                        <ItemTemplate>
                            <asp:HyperLink runat="server" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "ItemUrl")%>'
                                Text='<%# DataBinder.Eval(Container.DataItem, "ItemName")%>' />
                        </ItemTemplate>

                    </asp:TemplateField>

    在后台直接把"javascript:document.execCommand('Refresh');window.open(url);"赋值给ItemUrl就可以了。

    另一个后台绑定的方法http://hi.baidu.com/nthulu/blog/item/5e3197cb42d9f2fe52664f94.html

  • 相关阅读:
    You don't have permission to access / on this server.
    WampServer修改端口及菜单Localhost
    如何手机访问电脑服务器上的网页?
    Zed Shaw:程序员的常见健康问题
    js中匿名函数的N种写法
    HDU 1561 树形DP背包问题
    COJ 1156 Switching bulbs
    POJ 2891 Strange Way to Express Integers
    FZU 1402 猪的安家 中国剩余定理
    HDU 1573 解同余模线性方程组
  • 原文地址:https://www.cnblogs.com/Hary/p/GridView.html
Copyright © 2011-2022 走看看