Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nested MasterPages FindControl TextBox.

Posted on 2013-05-11
1
Medium Priority
?
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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