Solved

Nested MasterPages FindControl TextBox.

Posted on 2013-05-11
1
377 Views
Last Modified: 2013-06-07
In the following code and am trying to retrieve the text from a textbox from a child masterpage. The code returns a null value, I'm unsure why this returns null because in debug mode I am able to see value entered.
 
Parent Master:
                <!-- Content Body Holder -->
                <div style="border-width: 1em; border-color: #000;">
                    <asp:ContentPlaceHolder id="defaultBodyCPH" runat="server"></asp:ContentPlaceHolder>
                </div>

Child Master:
<asp:Content ID="Content2" ContentPlaceHolderID="defaultHeaderCPH" Runat="Server">
                    <!--This section contains the Website Search functionality -->
                    <div style="float: right; background:#fff; border:solid .1em #000;">
                        <asp:Textbox id="searchTB" runat="server" width="20em" height="2.25em" cssClass="searchBox" OnTextChanged="Search" />
                        <asp:ImageButton id="cmdSearch" runat="server" ImageUrl="~/images/searchIcon.png" ImageAlign="Middle" style="margin-left: -.5em;" onclick="Search"/>
                        <asp:textboxwatermarkextender runat="server" ID="searchTBWE" TargetControlID="searchTB" WatermarkText="Enter Search Criteria" WatermarkCssClass="watermarked" />
                    </div>
</asp:Content>

Codebehind:
'This code works in conjunction with the Event handler in the ListViewMasterPage VB code
            Dim masterPage As MasterPages_ListViewMasterPage = TryCast(Me.Master, MasterPages_ListViewMasterPage)
            Dim cp As ContentPlaceHolder = CType(Me.Master.Master.FindControl("defaultBodyCPH"), ContentPlaceHolder)
            'Dim db As ClientInfoDataContext = New ClientInfoDataContext
            Dim search As String
            If Not IsNothing(masterPage) Then
                Dim searchTBx As TextBox = CType(cp.FindControl("searchTB"), TextBox)
                search = searchTBx.Text
            End If
0
Comment
Question by:Robert Treadwell
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39164383
Is the code behind in the master masterpage or in content?

One option is to use a hidden field and set its value in javascript which you can then access on server side without looking for textbox itself.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now