我有一個帶有多個用戶控件的aspx頁面。 頁是這樣的,如何在每個用戶控件的一個aspx頁面上使用javascript pageLoad()事件?
<asp:Content ID="Content2" ContentPlaceHolderID="chpMainBody" runat="server">
<en:ProfileInfo ID="ucProfileInfo" runat="server" />
<br />
<en:WorkingExperienceInfo ID="ucWorkingExperienceInfo" runat="server" />
<br />
<en:TechnicalInfo ID="ucTechnicalInfo" runat="server" />
<br />
<en:EducationInfo ID="ucEducationInfo" runat="server" />
</asp:Content>
我與樹視圖dropdownextender每個用戶控制使用此腳本,這是「ucEducationInfo」用戶控件
<script type="text/javascript">
var DDE4;
var DDE5;
function pageLoad() {
DDE4 = $find('<%= dde_CountryUniversity.ClientID %>');
DDE5 = $find('<%= dde_UniversityMajors.ClientID %>');
DDE4._dropWrapperHoverBehavior_onhover();
DDE5._dropWrapperHoverBehavior_onhover();
$get('<%= pnl_CountryUniversity.ClientID %>').style.width = $get('<%= txt_CountryUniversity.ClientID %>').clientWidth;
$get('<%= pnl_UniversityMajors.ClientID %>').style.width = $get('<%= txt_UniversityMajors.ClientID %>').clientWidth;
if (DDE4._dropDownControl) {
$common.removeHandlers(DDE4._dropDownControl, DDE4._dropDownControl$delegates);
}
if (DDE5._dropDownControl) {
$common.removeHandlers(DDE5._dropDownControl, DDE5._dropDownControl$delegates);
}
DDE4._dropDownControl$delegates = {
click: Function.createDelegate(DDE4, ShowMe),
contextmenu: Function.createDelegate(DDE4, DDE4._dropDownControl_oncontextmenu)
}
DDE5._dropDownControl$delegates = {
click: Function.createDelegate(DDE5, ShowMe),
contextmenu: Function.createDelegate(DDE5, DDE5._dropDownControl_oncontextmenu)
}
$addHandlers(DDE4._dropDownControl, DDE4._dropDownControl$delegates);
$addHandlers(DDE5._dropDownControl, DDE5._dropDownControl$delegates);
}
function ShowMe() {
DDE4._wasClicked = true;
DDE5._wasClicked = true;
}
但我注意到素文字只能「ucEducationInfo」usercontrol。我嘗試改變usercontrol的行,我認爲這是因爲用戶控制在頁面的末尾。我對JavaScript不太好。哪裏不對?
好吧,我添加了腳本的頂部,它已經解決了Sys.Application.add_load(myEducationFunction); Sys.Application.add_load(ShowMe); var DDE4; var DDE5; 函數myEducationFunction()................ – tessa
非常感謝你 – tessa