Hi Naveen
Thank you very much. The following is my complete codes. No error alert, Nothing happened at all after I click the button. I don't know what's the problem with my codes. It seems the Java script only can be live by a control event initialization that like many people have done. It has broken my initial idea - calling javascript from VB or C# without a control event trigger.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim param1 As HtmlInputHidden = New HtmlInputHidden
param1.value = "Hi! I am a VB Parameter"
' Define the name and type of the client scripts on the page.
Dim csname1 As String = "ClientScript"
Dim csname2 As String = "MyJava()"
Dim cstype As Type = Me.GetType()
' Get a ClientScriptManager reference from the Page class.
Dim cs As ClientScriptManager = Page.ClientScript
' Check to see if the client script is already registered.
If (Not cs.IsClientScriptBlockRegistered(cstype, csname1)) Then
cs.RegisterClientScriptBlock(cstype, csname1, csname2)
End If
cs.RegisterStartupScript(cstype, csname1, csname2)
End Sub
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function MyJava(){
var FromVB = document.getElementById("param1").value;
alert(FromVB);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type = "hidden" id ="param1" />
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>