hi my dear friends:
The pages on my project are base on master and content pages...
I want to do something with javascript(rather than jquery) in one of content pages after ALL OF MASTER AND CONTENT ELEMENTS ARE LOADED COMPLETELY.(for example set focus on a RadComboBox Control)
For doing that I used the below code :
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="../JQuery/jquery-1.4.1.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
onload = onloadOfDocument;
function onloadOfDocument() {
var combo = $find("<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>");
alert(combo);
var comboInput = combo.get_inputDomElement();
comboInput.focus();
}
</script>
</asp:Content>
But alert(combo);
always returns null.(the $find
code is for telerik controls and the upper codes about telerik controls are completely true)
To solve this null
problem I test the ways shown below:
1- I Removed all of controls from master and content page except RadComboBox Control and null problem disappeared , so i derived the null peoblem is about all of elements of master and content page have not been loaded when
$find("<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>");
is fired.
2- so i used
$(document).ready(function() { my codes });
instead of
onload = onloadOfDocument;
but problem not solved - i do not know why!!!
3- at last i test the below code and it works perfectly :
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="../JQuery/jquery-1.4.1.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
//onload = onloadOfDocument;
document.onkeyup = onkeyupOfDocument;
function onkeyupOfDocument() {
var combo = $find("<%= RadcbPersonelCompleteNameInvwNoskhehEdit.ClientID %>");
alert(combo);
var comboInput = combo.get_inputDomElement();
comboInput.focus();
}
</script>
What function of document should i use for doing some javascript codes after all Of MASTER AND CONTENT ELEMENTS are loaded completely?
Thanks in future advance