我用下面的方式在回發時運行JavaScript,它對我來說工作得很好。在c上回傳一個JavaScript運行#
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","<script type='text/javascript'>document.getElementById('apDiv1').style.visibility = 'hidden';</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","<script type='text/javascript'>function show()</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","<script type='text/javascript'>document.getElementById('apDiv1').style.visibility = 'visible';</script>");
}
}
上面的代碼工作正常,現在我想嘗試下面的東西。
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"verify","<script type='text/javascript'>verify1();</script>");
}
else
{
}
}
在上面的代碼
verify1()
是外部連接到ASPX頁的腳本。我無法使用此代碼執行verify1()
函數。和verify1()
函數工作正常時,作爲<body onload="verify1();">
是否有任何語法錯誤(S)在我上面的代碼?
檢查[從asp.net C#頁面的外部JavaScript文件](http://stackoverflow.com/questions/5816672/external-javascript-file-from-asp-net-c-sharp-page)。 – Bastardo 2012-01-17 16:13:45