Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
$(document).ready(function ButtonEnable() {
            alert('hello');
        });

and code behind is
C#
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "ButtonEnable();", true);

this jquery did not worked though jquery loaded perfectly i checked but its not working (this function above...)

but when i use javascript its working well
code is...
JavaScript
function UpdateRow(btnid) {

            alert('hello');
        };

C#
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "UpdateRow("+btnadd+");", true);

can anyone please tell why jquery not worked but javascript worked.
Posted

Ok, you can do it like this. It functions


C#
<script type="text/javascript">
// this is a sample function
function functionName(name){
                alert(name);
            }

//calling the above defined function on page load using jquery
$(document).ready(functionName('some text'))

</script>

p.s. Please check if you have correctly loaded the jquery by putting this line in the body above this code

<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
 
Share this answer
 
v3
Comments
varun150 20-Jan-15 7:56am    
thankyou so much for your kind reply,

are you calling a javascript function by jquery i dont understand please explain a bit.

i think its a javascript syntex...

function FunctionName(name){
alert(name);
}
varun150 20-Jan-15 7:58am    
jquery and javascript is such a nightmare to me ,plelse...
i did it in javascript .i called jquery function from code behind using scriptmanager.registerstartupscriptblock method ,problem was, i was not declaring the parameter to be passed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900