在标记aspx页面中的Hyperlink标记上设置属性`OnClick`

时间:2016-08-03 09:12:48

标签: c# asp.net hyperlink popupwindow

在我的aspx页面的标记中,我设置了这个Hyperlink标记:

<asp:TemplateField HeaderText="myField">
    <ItemTemplate>
        <asp:HyperLink ID="myField" runat="server" NavigateUrl='<%# (String.IsNullOrEmpty(Eval("myField").ToString()) ? String.Format("Validate.aspx?sId={0}", Eval("id").ToString()) : "") %>'
            ImageUrl='<%#(String.IsNullOrEmpty(Eval("myField").ToString()) ? "/img/redbul.gif" : "/img/forestbul.gif")%>'
            ToolTip='<%#(String.IsNullOrEmpty(Eval("myField").ToString()) ? "empty" : "full")%>'
            Target="_blank" BorderStyle="None" ForeColor="Transparent" OnClick="window.open(this.href,'playsample','width=500,height=500,left=100,top=100,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=no,menubar=no,status=no,resizable=yes');return false;">
        </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>

并在属性OnClick上设置以在弹出窗口中打开新网页:

    OnClick="window.open(this.href,'playsample','width=500,height=500,left=100,top=100,  
  scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=no,menubar=no,
    status=no,resizable=yes');return false;">

但我无法:

  1. 在弹出窗口中打开新网页之前,在属性OnClick上设置确认弹出窗口;
  2. myfield的值已满时,阻止打开弹出窗口;在这种情况下,属性OnClick打开一个空的Web窗口。
  3. 你能帮助我吗?

    提前谢谢。

    编辑#1

    <td class="ddl_Class_new" align="center">
    <a id="gvProducts_ctl03_myField" title="Full" OnClick="if(!confirm(&#39;Continue ?&#39;))return false;
    window.open(this.href,&#39;playsample&#39;,&#39;width=500,height=500,left=100,top=100,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,
    directories=no,menubar=no,status=no,resizable=yes&#39;);return false;" target="_blank" style="display:inline-block;color:Transparent;border-style:None;">
    <img title="Full" src="/Img/forestbul.gif" alt="" style="border-width:0px;" /></a>
    </td>
    

1 个答案:

答案 0 :(得分:1)

  1. javascript,如果确认(....)window.open
  2. &#34;当myfield的值已满时#34; - 用jquery检查
  3. 编辑1:

    问题2的jquery:

    if($(&#34;#&lt;%#myField.ClientID%&gt;&#34;)。attr(&#39; value&#39;)==&#34; Full&#34;) )...

相关问题