0

I have used a user control to get data from database and render it as MegaMenu anchors. In code-behind file I have got data and rendered it by using a literal.

The megamenu.js file (containging myMega.Init method) has been inserted into header element

I have added following script tag into .ascx file.

<script type="text/javascript">
  myMega.Init("mer_id", "anchor_id", "click");
</script>

I have several .aspx files which have same master page. The master page registers the User Control and contains following tag exact before .

 <uc:MegaMenu id="anchors" runat="server"></uc:MegaMenu>

the problem is the myMega.Init only invokes when I go to firstpage.aspx. I have debugged by hitting f12 and choosing debugg Script. the init file invokes only first time (firstpage) not other pages. thank you for your help.

4

2 回答 2

0

是 mer_id 和 anchor_id 元素的 id 以及 .Init 做什么?

于 2013-03-31T17:03:45.183 回答
0

如果您使用 jquery 库,您可以将您的代码置于就绪事件中

<script type="text/javascript">
$(function() {
  myMega.Init("mer_id", "anchor_id", "click");
});
</script>
于 2013-05-02T16:34:24.987 回答