简体   繁体   English

如何在ASP.NET中使内部Java外部

[英]How to Make Internal Javascript in ASP.NET external

I have code in ASP.NET web form that make gridview header fixed. 我有ASP.NET Web表单中的代码,这些代码使gridview标头固定。

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script src="jquery/JQueryUICalendar/js/gridviewScroll.min.js"  type="text/javascript"></script>

<script type="text/javascript">
    var $160 = jQuery.noConflict();
    $160(document).ready(function () {
        gridviewScroll();
    });

    function gridviewScroll() {
        $160('#<%=grdLeasingReport1.ClientID%>').gridviewScroll({
            width: 1080,
            height: 350,

        });
    }
</script>

This is inline with the aspx WITH GRIDVIEW which is using that as reference. 这与使用aspx WITH GRIDVIEW作为参考的内联。 I want to make it in external file along with my other js scripts, but it is not working after doing that. 我想将其与其他js脚本一起放在外部文件中,但这样做后不起作用。

<%=grdLeasingReport1.ClientID%>

is not Javascript but code from .Net. 不是Javascript,而是.Net的代码。

That's probably why it's inline javascript. 这可能就是为什么它是内联javascript。 If it's possible, and not a breach of security, one way to force the issue is to make the clientid part of the url querystring, then grab it with javascript to use in your gridviewScroll function. 如果可能的话,并且不违反安全性,强制此问题的一种方法是使clientid成为url查询字符串的一部分,然后使用javascript抓取它以在gridviewScroll函数中使用。

Use this as reference for taking on this task: How can I get query string values in JavaScript? 以此作为执行此任务的参考: 如何获取JavaScript中的查询字符串值?

as for putting the grdLeasingReport1.ClientID in the url querystring, it will just depend on how you "arrive" at the page in question. 至于将grdLeasingReport1.ClientID放在url查询字符串中,则仅取决于您如何“到达”相关页面。 I don't know if this will help; 我不知道这是否有帮助; but it's one way to pull the javascript from inline and into a linked .js file. 但这是将JavaScript从内联方式拉入链接的.js文件的一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM