Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i want to write a javascript in .net.
example script:
C#
function enableForm() {
     document.getElementById("form").disabled = false;
 }

 window.onLoad = enableForm();


where i want to include this script can anybody help?.thanks
Posted

Try this.
XML
<html>
<head id="Head1" runat="server">
  <script type="text/javascript" language="javascript">
function enableForm() {
     document.getElementById("form").disabled = false;
 }
</head>
<body  önload="enableForm()">
.
.
.
</body>

</body>
 
Share this answer
 
v2
Comments
#realJSOP 6-Sep-11 7:58am    
5 - proposed as answer
Start with this[^] tutorial.
 
Share this answer
 
you can try this one too.
C#
string myScriptValue = "function enableForm() {document.getElementById("form").disabled = false;}window.onLoad = enableForm();";

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myScriptName", myScriptValue, true);


I have never debug this so im not sure if its syntax free :)
 
Share this answer
 
Comments
parithi vr 7-Sep-11 0:36am    
exactly where should i want to write the code. thanks for the answer
Jephunneh Malazarte 7-Sep-11 3:25am    
you can write that code in your event function.
but remember that, that client code will be executed only after the postback is completed.
Jephunneh Malazarte 8-Sep-11 0:26am    
http://cebucoders.blogspot.com/2011/07/how-to-display-javascript-message-after.html
for add-on sample :)

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