2 Replies - 180 Views - Last Post: 01 July 2019 - 07:26 AM Rate Topic: -----

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 634
  • View blog
  • Posts: 4,209
  • Joined: 12-January 10

trying to find control results in Nothing

Posted 01 July 2019 - 05:21 AM

so i need to find all the controls on a page because i have to be able to make it spanish/english



i have tried the following:
 Dim st As String = "lblDate"
        Dim lbl As Label = TryCast(Page.FindControl(st), Label)
        If lbl IsNot Nothing Then
            lbl.Text = "Test"
        End If



and

     Dim cControl As Control
        For Each cControl In Controls
           If (TypeOf cControl Is SiteMaster) Then
               For Each c As Control in cControl.Controls
                  If (TypeOf c Is ContentPlaceHolder) then
                       for each con in c.Controls
                           If (TypeOf con Is Label) Then
                                Dim Lbl As Label = DirectCast(cControl, Label)
                                Lbl.Text = "test"
                           End If
                        next
                    end if
                Next
            End if 
        Next cControl



it always says the control is asp.site_master no matter what

here is the top section just so you can see what i am looking for


<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="HourlyEntry2.aspx.vb" Inherits="DownTime.HourlyEntry2" %>




<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Panel runat="server" id="MainHourlyEntry2" >
        <div class="divContainerMain2">
            <asp:Panel runat="server" CssClass="PanelContainerHeader">
                <div class="divContainerHeader">
                    <div class="divContainerHeaderInside"><asp:Label runat="server" id="lblDate" AssociatedControlID="txtDate" CssClass="labelNormal" text="Date: "></asp:Label><asp:TextBox runat="server" ID="txtDate" CssClass="textboxStyle3ReadOnly" ReadOnly="True" TabIndex="-1"></asp:TextBox></div>
                </div>


notice the date label



is there a way to get the controls ?

Is This A Good Question/Topic? 0
  • +

Replies To: trying to find control results in Nothing

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,187
  • Joined: 12-June 08

Re: trying to find control results in Nothing

Posted 01 July 2019 - 05:41 AM

Have you thought about going the 'globalization' route?

https://docs.microso...n/globalization
https://docs.microso...27427(v=vs.140)
Was This Post Helpful? 0
  • +
  • -

#3 DarenR   User is offline

  • D.I.C Lover

Reputation: 634
  • View blog
  • Posts: 4,209
  • Joined: 12-January 10

Re: trying to find control results in Nothing

Posted 01 July 2019 - 07:26 AM

i actually suggested that but i was told database driven is what they want--

so now back to finding the controls ha
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1