0

I have code in ASP.NET web form that make gridview header fixed.

 <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. I want to make it in external file along with my other js scripts, but it is not working after doing that.

5
  • 1
    Probably because $160('#<%=grdLeasingReport1.ClientID%>') is not JS, and will not run in a JS file. Commented Jun 7, 2016 at 3:58
  • $160('#<%=grdLeasingReport1.ClientID%>') this is Server control ID , and can use after rendering all page. so you can put this piece of code an external js but you must add the external JS link at the bottom of aspx page Commented Jun 7, 2016 at 4:16
  • I see. So that line of code is not a js code, so are there ways to put that line of code in the ecternal js file? Commented Jun 7, 2016 at 5:21
  • hi @Nazir actually the external js is already linked in the master page where this page is using. and i put the code in that external js file Commented Jun 7, 2016 at 5:23
  • actully some pages render before , after loading entire master page, that's why the code can't access the server control ID , for testing purpose an external js page create and put the link on bottom of this aspx page , Commented Jun 7, 2016 at 5:58

1 Answer 1

1

<%=grdLeasingReport1.ClientID%>

is not Javascript but code from .Net.

That's probably why it's inline 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.

Use this as reference for taking on this task: How can I get query string values in JavaScript?

as for putting the grdLeasingReport1.ClientID in the url querystring, it will just depend on how you "arrive" at the page in question. 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.