繁体   English   中英

ASP.NET LinkBut​​ton子控件在回发后消失

[英]Asp .net Linkbutton child controls dissapears on postback

我有一个asp .net超链接控件声明如下:

  <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>

我的问题是linkbutton的内容在回发时消失了。 任何想法为什么会这样?

在加载时,我在linkbutton或其子代上执行以下代码:

                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;

一个推测...

我相信您可能在if(!IsPostBack)内的Page_Load (或Init )中有代码

如果是这种情况,请将其移至该if语句之外,因为您需要它作为对liveChatCtrl默认visiblefalse

要么重新编码,要么使默认visible为true,然后对回发进行检查以在需要时将其隐藏。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM