for each webcontrol

Discussion in 'ASP .Net Web Controls' started by tommy, Oct 13, 2003.

  1. tommy

    tommy Guest

    hello,

    i know how to set values for each control on my windows-form.
    but how to do this in asp.net??

    example for windows-forms:

    dim txtBox as Textbox
    dim myControl as Control

    for each mycontrol in control

    is typeof mycontrol is textbox then
    txtbox.text = "Hello"
    end if

    next


    for each mycontrol in webcontrol doesnt work

    suggestions?


    best regards

    tommy
    tommy, Oct 13, 2003
    #1
    1. Advertising

  2. Hi Tommy,

    Please try the following:

    Dim ctl As Control
    For Each ctl In Page.Controls(1).Controls
    If TypeOf ctl Is TextBox Then
    CType(ctl, TextBox).Text = "hello"
    End If
    Next

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > From: (tommy)
    > Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    > Subject: for each webcontrol
    > Date: 13 Oct 2003 07:02:33 -0700
    > Organization: http://groups.google.com
    > Lines: 27
    > Message-ID: <>
    > NNTP-Posting-Host: 217.111.48.57
    > Content-Type: text/plain; charset=ISO-8859-1
    > Content-Transfer-Encoding: 8bit
    > X-Trace: posting.google.com 1066053753 6514 127.0.0.1 (13 Oct 2003

    14:02:33 GMT)
    > X-Complaints-To:
    > NNTP-Posting-Date: Mon, 13 Oct 2003 14:02:33 +0000 (UTC)
    > Path:

    cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
    8.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!
    news.maxwell.syr.edu!postnews1.google.com!not-for-mail
    > Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webcontrols:15320
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    >
    > hello,
    >
    > i know how to set values for each control on my windows-form.
    > but how to do this in asp.net??
    >
    > example for windows-forms:
    >
    > dim txtBox as Textbox
    > dim myControl as Control
    >
    > for each mycontrol in control
    >
    > is typeof mycontrol is textbox then
    > txtbox.text = "Hello"
    > end if
    >
    > next
    >
    >
    > for each mycontrol in webcontrol doesnt work
    >
    > suggestions?
    >
    >
    > best regards
    >
    > tommy
    >
    Mike Moore [MSFT], Oct 14, 2003
    #2
    1. Advertising

  3. Hello Mike,

    thank you very much- its work fine !!! :)



    best regards from munich


    tommy

    ----------------------------------------
    HangulHanjaFastConversion-Eigenschaft

    True if Microsoft Word automatically converts a word with
    only one suggestion during conversion between hangul
    and hanja. Read/write Boolean.
    ----------------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    thomas hauser, Oct 15, 2003
    #3
  4. tommy

    Maras Guest

    Hi Mike,

    > Dim ctl As Control
    > For Each ctl In Page.Controls(1).Controls
    > If TypeOf ctl Is TextBox Then
    > CType(ctl, TextBox).Text = "hello"
    > End If
    > Next
    >


    Could you explain me why the index is 1 (Page.Controls(1).Controls) and not
    for example 0 ?

    Thanks a lot,
    cheers

    --
    Maras
    Maras, Oct 15, 2003
    #4
  5. Hi Maras,

    Control(0) is the header. Control(1) is the form. All the web controls are
    in the form.

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > From: "Maras" <>
    > Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    > Subject: Re: for each webcontrol
    > Date: Wed, 15 Oct 2003 16:16:34 +0200
    > Organization: news.onet.pl
    > Lines: 18
    > Sender: @pd9e0eb53.dip.t-dialin.net
    > Message-ID: <bmjks3$dlu$>
    > References: <>

    <bX#A#>
    > NNTP-Posting-Host: pd9e0eb53.dip.t-dialin.net
    > Mime-Version: 1.0
    > Content-Type: text/plain;

    charset="iso-8859-2"
    > Content-Transfer-Encoding: 7bit
    > X-Trace: news.onet.pl 1066227395 14014 217.224.235.83 (15 Oct 2003

    14:16:35 GMT)
    > X-Complaints-To:
    > NNTP-Posting-Date: 15 Oct 2003 14:16:35 GMT
    > X-Priority: 3
    > X-MSMail-Priority: Normal
    > X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > Path:

    cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfee
    d01.sul.t-online.de!t-online.de!newsfeed.tpinternet.pl!newsfeed.gazeta.pl!ne
    ws.onet.pl!not-for-mail
    > Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webcontrols:15389
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    >
    > Hi Mike,
    >
    > > Dim ctl As Control
    > > For Each ctl In Page.Controls(1).Controls
    > > If TypeOf ctl Is TextBox Then
    > > CType(ctl, TextBox).Text = "hello"
    > > End If
    > > Next
    > >

    >
    > Could you explain me why the index is 1 (Page.Controls(1).Controls) and

    not
    > for example 0 ?
    >
    > Thanks a lot,
    > cheers
    >
    > --
    > Maras
    >
    Mike Moore [MSFT], Oct 15, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    2
    Views:
    725
  2. Luis Ramírez.

    Can a webcontrol (webcontrol.dll) have a configuration file?

    Luis Ramírez., Jul 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    185
    Luis Ramírez
    Jul 6, 2004
  3. Kasabaarde Sumta

    WebControl inside of WebControl and attaching events

    Kasabaarde Sumta, Dec 13, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    177
    Kasabaarde Sumta
    Dec 13, 2004
  4. Fabricio

    Custom webcontrol that references another webcontrol

    Fabricio, Sep 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    171
    Fabricio
    Sep 21, 2005
  5. Peter Morris [Air Software Ltd]

    WebControl with non-WebControl property

    Peter Morris [Air Software Ltd], Dec 7, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    127
    Peter Morris [Air Software Ltd]
    Dec 7, 2004
Loading...

Share This Page