By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,972 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,972 IT Pros & Developers. It's quick & easy.

ASP:TextBox

P: n/a
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default,
I want to display the customer's basic information in the
TextBox on Page_Load... but, also allow user to update the
information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same
text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex
Nov 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Try the attribute "text" instead of "value".

The best way to do this is declare an ASP textbox in the code-behind page
and assign the value of the variable to dbStreet1.Text from the Page_Load
event.

George Zacharias.

"Alex" <al******@gwu.edu> wrote in message
news:00****************************@phx.gbl...
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default,
I want to display the customer's basic information in the
TextBox on Page_Load... but, also allow user to update the
information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same
text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex

Nov 17 '05 #2

P: n/a
Hi,

This is what I did...

Page_Load()
dbStreet1.Text = "whatever st"

Update_Text()
SQL update cmd ==> "update ..... dbstreet1='" &
dbStreet1.Text "' where <match critera>=<match this>"

Inside the HTML Main Body
<form method=post>
<ASP:TextBox id=dbStreet1 value=dbStreet1.Text
runat=server/>
</form>

It works on initial load.. where it takes the info from
DB... but the update doesn't seem to regonize the new value

Any clue?
thanks
Alex
-----Original Message-----
Try the attribute "text" instead of "value".

The best way to do this is declare an ASP textbox in the code-behind pageand assign the value of the variable to dbStreet1.Text from the Page_Loadevent.

George Zacharias.

"Alex" <al******@gwu.edu> wrote in message
news:00****************************@phx.gbl...
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default, I want to display the customer's basic information in the TextBox on Page_Load... but, also allow user to update the information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex

.

Nov 17 '05 #3

P: n/a
Hi,

This is what I did...

Page_Load()
dbStreet1.Text = "whatever st"

Update_Text()
SQL update cmd ==> "update ..... dbstreet1='" &
dbStreet1.Text "' where <match critera>=<match this>"

Inside the HTML Main Body
<form method=post>
<ASP:TextBox id=dbStreet1 value=dbStreet1.Text
runat=server/>
</form>

It works on initial load.. where it takes the info from
DB... but the update doesn't seem to regonize the new value

Any clue?
thanks
Alex
-----Original Message-----
Try the attribute "text" instead of "value".

The best way to do this is declare an ASP textbox in the code-behind pageand assign the value of the variable to dbStreet1.Text from the Page_Loadevent.

George Zacharias.

"Alex" <al******@gwu.edu> wrote in message
news:00****************************@phx.gbl...
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default, I want to display the customer's basic information in the TextBox on Page_Load... but, also allow user to update the information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex

.

Nov 17 '05 #4

P: n/a
Alex,

You have to read some fundamental books on ASPX programming - that's #1.
There are bunches and bunches of inexpensive, quick, easy books on the
subject.

The Page_load event fires on every trip to your page, so you are overwriting
the data changed on the site with the Page_Load event assignments.
.... so, your fresh, new values are trampled on when you post back to
update...

events fired in this order:

Init
Load viewstate
Process postback data (this is where your new data gets back to the
application)
Load (this is were you lose the data, and the original values are put back)
Send postback Change
Postback events
pre-render
save view state
render
dispose
unload

Learn it, love it, live it! :-)

"Alex" <al******@gwu.edu> wrote in message
news:00****************************@phx.gbl...
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default,
I want to display the customer's basic information in the
TextBox on Page_Load... but, also allow user to update the
information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same
text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex

Nov 17 '05 #5

P: n/a
Dave,

Many thanks...

The sequence of load instructions solve my problem...
Basically I have everything else done right... Except, not
checking explicitly for POST during Page_Load...

I was basically counting on the even handler to trigger
the event..

Thank you
Alex
-----Original Message-----
Alex,

You have to read some fundamental books on ASPX programming - that's #1.There are bunches and bunches of inexpensive, quick, easy books on thesubject.

The Page_load event fires on every trip to your page, so you are overwritingthe data changed on the site with the Page_Load event assignments..... so, your fresh, new values are trampled on when you post back toupdate...

events fired in this order:

Init
Load viewstate
Process postback data (this is where your new data gets back to theapplication)
Load (this is were you lose the data, and the original values are put back)Send postback Change
Postback events
pre-render
save view state
render
dispose
unload

Learn it, love it, live it! :-)

"Alex" <al******@gwu.edu> wrote in message
news:00****************************@phx.gbl...
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default, I want to display the customer's basic information in the TextBox on Page_Load... but, also allow user to update the information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex

.

Nov 17 '05 #6

P: n/a

This event sequence, indeed, is discussed in several
ASP.NET with varying degrees of clarity. The major theme
in most books is to use the "if (!IsPostBack)..." logic to
get around the overwriting of variables in the viewstate.
However, I am observing a difference in behavior between
the asp:label control (where everything seems to work as I
expect and state is preserved via the viewstate) and the
asp:textbox where the state is not preserved in the
viewstate. What is happening here? I think Alex and I
are hitting the same problem.

Also, the instance of the asp:textbox seems not to have
been created in the init and when it is referenced in the
Page_Load an exception is thrown because the object isn't
there!

What is happening with the asp:textbox?
-----Original Message-----
Alex,

You have to read some fundamental books on ASPX programming - that's #1.There are bunches and bunches of inexpensive, quick, easy books on thesubject.

The Page_load event fires on every trip to your page, so you are overwritingthe data changed on the site with the Page_Load event assignments..... so, your fresh, new values are trampled on when you post back toupdate...

events fired in this order:

Init
Load viewstate
Process postback data (this is where your new data gets back to theapplication)
Load (this is were you lose the data, and the original values are put back)Send postback Change
Postback events
pre-render
save view state
render
dispose
unload

Learn it, love it, live it! :-)

"Alex" <al******@gwu.edu> wrote in message
news:00****************************@phx.gbl...
I am a newbie to ASP.NET...

What I was trying to do... but yet to succeed in...

I am building a customer info database... and on default, I want to display the customer's basic information in the TextBox on Page_Load... but, also allow user to update the information

For example: Street1 of the home address
ASP:TextBox id=dbStreet1 value=<%=litDbStreet1%>

but also allow update all within the same form on the same text box to do the following...
ASP:TextBox id=dbStreet1 runat=server

I tried everything I know... but not works...

Please advise
thanks
Alex

.

Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.