|
发表于 2020-11-10 09:30:01
|
显示全部楼层
用RegisterClientScriptBlock()
如下:
<html>
<head>
<script language="C#" runat="server">
public void Page_Load(Object sender, EventArgs e)
{
if (!this.IsClientScriptBlockRegistered("clientScript"))
{
// Form the script that is to be registered at client side.
String scriptString = "<script language=JavaScript> function DoClick() {";
scriptString += "myForm.show.value='Welcome to Microsoft .NET'}<";
scriptString += "/";
scriptString += "script>";
this.RegisterClientScriptBlock("clientScript", scriptString);
}
}
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="text" id="show" style="width=200"> <input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>
|
|