hyperLinkField中的DataNavigateUrlFormatString属性不能执行javascript的解决办法

文章摘自:
http://www.cnblogs.com/sdikerdong/archive/2011/07/31/2122724.html

今天在做案子时候遇到用GridView控件时,想在里面有一个hyperlink,点击后弹出窗口再显示另外页面。可是在用DataNavigateUrlFormatString属性时,发现

http://blogs.msdn.com/b/jjameson/archive/2009/10/26/datanavigateurlformatstring-does-not-allow-javascript.aspx


    ...
    
        <%-- HACK: Ideally, we would just use an asp:HyperLinkField,
        but there's a bug when specifying "javascript:" in the
        DataNavigateUrlFormatString:

        https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102300

        As a workaround, use a TemplateField instead. --%>
        
           Date
           
           
               
                   <%# Eval("CreateTime", "{0:ddd MMM dd HH:mm}") %>
               
           
        
        ...
    

另外一种是用DataTextFormatString代替DataNavigateUrlFormatString。

http://www.vbforums.com/showthread.php?t=521952

你可能感兴趣的:(hyperLinkField中的DataNavigateUrlFormatString属性不能执行javascript的解决办法)