i have this function on my aspx page:
<script type="text/javascript">
function pageLoad() {
//code here
}
</script>
and i need to override this function dymanically from my .cs
i have tried to use Page.ClientScript.RegisterClientScriptBlock
and Page.ClientScript.RegisterStartupScript
but that only creates a new javascript function.
Any ideas?
Try creating an empty div on your ASPX page with runat="server"
, and then setting the InnerHtml
to the JavaScript code. This offers a lot of flexibility and will allow you to apply whatever logic you need depending on your situation.
.aspx
<div id="script" runat="server">
</div>
.cs
script.InnerHtml = "<script type='text/javascript'>//your javascript here</script>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.