Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > control value after submit

Reply
Thread Tools

control value after submit

 
 
psb
Guest
Posts: n/a
 
      01-13-2004
QUESTION IS AT BOTTOM...

------------- ASPX -----------------------------------------
<form id="form1" runat="server">
<asplaceholder 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


 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-14-2004
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">
> <asplaceholder 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
>
>



 
Reply With Quote
 
 
 
 
psb
Guest
Posts: n/a
 
      01-14-2004
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">
> > <asplaceholder 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
> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-14-2004
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">
> > > <asplaceholder 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text box value keeps resetting after submit hai.mailbox@gmail.com Javascript 1 06-23-2008 05:23 PM
submit after value returned from popup window Man-wai Chang Javascript 2 04-26-2007 01:47 PM
How To Save value in page and use that value After Submit? Joel Javascript 3 11-24-2004 05:21 AM
HtmlInputFile.value cleared after submit. Lau Lei Cheong ASP .Net 3 05-19-2004 02:28 AM
Can't retrieve selected text/value of SelectionList after submit - URGENT domchik ASP .Net Mobile 1 09-04-2003 01:32 PM



Advertisments