2013-06-18 24 views
0

自敗我宣佈這樣一個ASP.NET的超級鏈接控制:的ASP.NET LinkBut​​ton的子控件在回發

<li runat="server" id="liveChatCtrl" Visible="false"><asp:LinkButton runat="server" ID="hlnkLiveChat" CausesValidation="false" OnClick="hlnkLiveChat_Click">Live Chat Support <i class="icon icon_next_03 fr"></i><i runat="server" id="iconChat" class="icon_chat_online"></i></asp:LinkButton></li> 

我的問題是LinkBut​​ton的內容回發上消失。任何想法爲什麼發生這種情況?

在負載我執行上LinkBut​​ton的下面的代碼或它的孩子們:

   string absoluteURL = UtilManager.Settings.Item(Utils.BrandID, "URL:absoluteURL"); 
      string chatLink = "StartChat.aspx"; 
      if (HttpContext.Current.User.Identity.IsAuthenticated) 
       chatLink = "LiveChat.aspx";//~/ 
      //else 
      // chatLink = "SalesChat.aspx"; 
      string link = absoluteURL + chatLink; 
      hlnkLiveChat.Attributes["onclick"] = string.Format("javascript:window.open('{0}', 'chat', 'status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,height=505,width=420,left=30,top=30');", link);//"openPopup('" + link + "','chat'); return false;";    
      liveChatCtrl.Visible = true; 
+0

你在哪裏執行超鏈接內容的代碼? – Andrei

+0

在頁面初始化事件 – Alecu

+0

需要檢查的東西,如果該'LinkBut​​ton'內容被封裝在一個'if(!Page.IsPostback())'中,它將首先被渲染,然後在回發中消失。 – fnostro

回答

1

猜...

我相信你可以有代碼在你Page_Load(或Init)內的if(!IsPostBack)

如果是這樣的話,移動它這個if聲明之外,因爲你需要它來爲您的默認visible運行你liveChatCtrlfalse

要麼或重新編碼一點點,以便您的默認visible是真實的,你運行檢查回發隱藏它,如果需要。

相關問題