Solved

Nested MasterPages FindControl TextBox.

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 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