且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当控件不可见时,页面内容中母版页的Findcontrol不起作用

更新时间:2023-10-17 18:41:40

当组件不可见时查看页面的来源,你看到你的PanMsg div在源头?不,因为如果它不可见,它不会被呈现或发送给客户端,那么你的js如何与它互动呢?



如果你想让一些东西可见客户端然后不要将Visible属性设置为false,而是改变它的样式并将样式设置为display:none;



抢占你的下一个问题google在asp:panel上设置样式以了解如何操作。
When the component is not visible view the source of the page, do you see your PanMsg div in the source? No, because if it's not visible it isn't rendered or sent to the client so how can your js interact with it?

If you want to make something visible on the client side then don't set the Visible property to false, instead alter it's style and set the style to "display:none;"

To preempt your next question google "set style on asp:panel" to find out how to do that.


2k89Tg1KHEPF
2k89Tg1KHEPF
You can do the following,

add property runat="server" to the control of master page which you want to access on the main page.(ingore if already added)

after that in the page load event of the page write following,

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Web.UI.MasterPage mp = this.Master;
        System.Web.UI.HtmlControls.HtmlInputText txtMasterPage = (System.Web.UI.HtmlControls.HtmlInputText)mp.FindControl("txtInputMaster");
        if(txtMasterPage.Visible == false)
        lblPage.Text = lblPage.Text + ":" + txtMasterPage.Value;
    }

this will definitely work