How to assign values to controls on MASTERPAGE.

Source: Internet
Author: User

If masterPage is used in. net 2.0, you cannot use FindControl as before. You need to use the following method:

First find ContentPlaceHolder, and then find the control you are looking for in this ContentPlaceHolder


1
2 // ContentPlaceHolder ID in MasterPage
3 string masterPageContentPlaceHolderID = "";
4 // ID of the control to be found in masterPageContentPlaceHolderID
5 string m_strSetDataToID = "";
6 // For example, search for TextBox
7 TextBox textBoxFind = (TextBox) this. Page. Master. FindControl (masterPageContentPlaceHolderID). FindControl (m_strSetDataToID );

Http://www.cnblogs.com/forward/articles/masterpage.html

ContentPlaceHolder mpContentPlaceHolder;
Label mpTextBox;
MpContentPlaceHolder =
(ContentPlaceHolder) Master. FindControl ("home ");
If (mpContentPlaceHolder! = Null)
{
MpTextBox = (Label) mpContentPlaceHolder. FindControl ("ctl00_member_name ");
If (mpTextBox! = Null)
{
MpTextBox. Text = "TextBox found! ";
}
Else
{
Response. Write ("Label fdfd ");
}
}
Else
{
Response. Write ("ContentPlaceHolder fdfd ");
}

There are still problems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.