要在post back后使用javascript保留在服务器控件上设置的值,可以使用以下解决方法:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "RestoreValue", "restoreValue();", true);
}
}
这样,当post back后,javascript将使用隐藏字段中的值来恢复服务器控件上的设置值。