Solved

Nested MasterPages FindControl TextBox.

Posted on 2013-05-11
1
382 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

809 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