使用Masterpage跟用户控件时,在指定页面的Head加载Javascript
当我们使用博客,然后使用页面中有用户控件,我们只想在指定的页面HEAD中
载入javascript,我们可先把javascript存成js文件然后添加下面的语句到pageonload
中就可以了。
HtmlGenericControl Include = new HtmlGenericControl("script");
Include.Attributes.Add("type", "text/javascript");
Include.Attributes.Add("src","/JS/HouseSalePriceRangeDropDownList.js");
this.Page.Header.Controls.Add(Include);
string onchangeValue = "go(" + "'"+ddlHouseSaleType.ClientID+"'" + ")";
ddlHouseSaleType.Attributes.Add("onchange", onchangeValue);