请问 如何在后台给 <body>, 增加客户端事件 例如:<body onload="alert('')"
请问 如何在后台给 <body> , 增加客户端事件 例如: <body onload= "alert( ' ') "
------解决方案--------------------sorry for my misunderstanding :)
MasterPage.master-
<body runat= "server " id= "body ">
<form id= "form1 " runat= "server ">
<div>
<asp:contentplaceholder id= "ContentPlaceHolder1 " runat= "server ">
</asp:contentplaceholder>
</div>
</form>
</body>
Default.aspx-
<%@ Page Language= "C# " MasterPageFile= "~/MasterPage.master " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>
<asp:Content ID= "content1 " runat= "server " ContentPlaceHolderID= "ContentPlaceHolder1 ">
</asp:Content>
Default.aspx.cs-
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), " ", " <script> document.getElementById( 'ctl00_body ').onload =function(){alert( 'liuliu ');} </script> ");
}