hi paul, it is not retraing the value coz you are loading the control only
the first time. Controls loaded dynamically need to be rebuilt even after
postback. Use the page_load sub, which will fire always, even after
postback. The best places to create dynamic controls and add them to the
controls collection is in the pageInit method or page_load .
Now this should work. When i posted last, I had given your code a quick look
as usual and missed your Page_load method, thought you already knew this.
You have an ispostback check in your page, i guess you are thinking it will
loose its initial values if you reloaded it even after postback, but this is
wrong. It wont loose its value, it will actually maintain its state and work
correctly.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
plhA.controls.add(LoadControl("c:\webs\myControl.a scx"))
end sub
"psb" <> wrote in message
news:%...
> first, thanks for replying.
>
> unfortunately, while in the btnS_serverclick(), if I load the control
again,
> it seems like it initializes it again. like it is loading the control for
> the first time. so, the txb1 is not NOTHING, but it is empty. I believe
> what I am trying to do is read a dynamically loaded control from the
> viewstate. any control dynamically loaded like this is not in the view
> state.
>
> again, thanks,
> -Paul
>
>
> "Alessandro Zifiglio" <> wrote in
> message news:qX6Nb.2835$...
> > I havent tested but this should be working for you.
> >
> > Dim textbox1 As TextBox
> > dim myTextboxValue as string
> > Dim c1 As Control
> > c1 = LoadControl("myControl.ascx")
> > textbox1 = c1.FindControl("txb1")
> > mytextboxvalue = textbox1.text
> >
> >
> >
> > "psb" <> wrote in message
> > news:...
> > > QUESTION IS AT BOTTOM...
> > >
> > > ------------- ASPX -----------------------------------------
> > > <form id="form1" runat="server">
> > > <asp
laceholder id="plhA" runat="server"/>
> > > <input type="submit" id="btnS" runat="server"/>
> > > </form>
> > >
> > > -------------------
> > > myControl.ascx ---------------------------------------------
> > > <input type="text" id="txb1" runat="server"/>
> > >
> > > -------------- code
> > > behind --------------------------------------------------
> > > function page_load()
> > > if not page.ispostback then
> > > plhA.controls.add(LoadControl("c:\webs\myControl.a scx"))
> > > end if
> > > end function
> > > ------------------------------------------
> > > function btnS_Serverclick()
> > > Page.FindControl("txb1") 'IS NOTHING WHY??
> > > plhA.FindControl("txb1") 'IS NOTHING WHY??
> > > request.form("_ctl45_txb1") IS CORRECT!!!
> > > end function
> > >
> > > HOW DO I GET THE VALUE OF THE TEXT BOX WITHOUT USING REQUEST.FORM()
> INSIDE
> > > btnS_Serverclick() FUNCTION???
> > >
> > > thanks,
> > > ~psb
> > >
> > >
> >
> >
>
>