Hi,
I've been working on a page and doing most of the code on the clientside. To keep the page tidy I wanted to move all the code in to a .js file and work in there. When I move the code the rowselected becomes undefined. Is it possible to move the code?
Thanks
I've been working on a page and doing most of the code on the clientside. To keep the page tidy I wanted to move all the code in to a .js file and work in there. When I move the code the rowselected becomes undefined. Is it possible to move the code?
Thanks
7 Answers, 1 is accepted
0

Stuart Hemming
Top achievements
Rank 2
answered on 26 Sep 2011, 08:42 AM
Karl,
Can you show us the code you're using in this function?
I suspect the problem is in the fact you have something like ...
in your function.
--
Stuart
Can you show us the code you're using in this function?
I suspect the problem is in the fact you have something like ...
var
grid = $find(
"<%=RadGrid1.ClientID%>"
);
--
Stuart
0

Karl
Top achievements
Rank 1
answered on 26 Sep 2011, 10:00 AM
Hi,
That's correct it does, so guess it can't be done then?
Thanks
That's correct it does, so guess it can't be done then?
Thanks
0
Accepted

Stuart Hemming
Top achievements
Rank 2
answered on 26 Sep 2011, 10:18 AM
Not so, you just need to be a bit cleverer.
if you are simply moving your code to a .js file, you need to make sure that the values are set on the page itself, for example...
Your .aspx file ...
In your .js file you just reference this variable.
If you are creating a single JavaScript object that has methods replacing the separate JS functions in your mark-up, you should pass the values in to the contructor for the object from within a <script> tag in your mark-up.
--
Stuart
Don't forget to mark this thread as answered.
if you are simply moving your code to a .js file, you need to make sure that the values are set on the page itself, for example...
Your .aspx file ...
<script type=
"text/javascript"
>
var
grid = $find(
"<%= RadGrid1.ClientID %>"
);
// any other such definitions go here
</script>
In your .js file you just reference this variable.
If you are creating a single JavaScript object that has methods replacing the separate JS functions in your mark-up, you should pass the values in to the contructor for the object from within a <script> tag in your mark-up.
--
Stuart
Don't forget to mark this thread as answered.
0

Karl
Top achievements
Rank 1
answered on 26 Sep 2011, 01:46 PM
Thanks, will give that a shot.
0

Karl
Top achievements
Rank 1
answered on 26 Sep 2011, 01:56 PM
Hi,
Just tried that and I get grid is null, of course I've changed the name to the name of my grid.
Thanks
Just tried that and I get grid is null, of course I've changed the name to the name of my grid.
Thanks
0

Stuart Hemming
Top achievements
Rank 2
answered on 26 Sep 2011, 02:12 PM
And is anything assigned to the grid variable?
Just looking at some code of mine, for grids I did this ...
And wired up the client-side event OnGridCreated.
Sorry to have mislead you; it's been a while since I was in there.
--
Stuart
Just looking at some code of mine, for grids I did this ...
var
grid;
function
OnClientGridCreated(sender, e)
{
grid = sender;
}
And wired up the client-side event OnGridCreated.
Sorry to have mislead you; it's been a while since I was in there.
--
Stuart
0

Karl
Top achievements
Rank 1
answered on 27 Sep 2011, 08:34 AM
Hi,
Thats the part I needed, thanks
Thats the part I needed, thanks