Monday, March 26, 2012

The control values are not sent to the form code.

I am new to Web Forms and I ported my little app from Windows Forms to
ASP.NET and I am wondering why some things are not working as before.
Although I figured most of them, one of them is that on my form I have input
fields and a button causing to store all the input fields into the database.
However, when in the button OnClick event I gather all the form control
values by either getting txtBox.Text or lstChoice.SelectedItem, all the
values are not equal to the user choices, but to the values last set by the
form programatically on Form Load. It looks that I am missing some event tha
t
sends the user control values from the client to the server.
Am I missing something?
Thank you
Cezar MartCezar:
Take a look at http://openmymind.net/FAQ.aspx?documentId=2
short answer is you need to wrap the code which initially sets the values in
a if not page.IsPostback then
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Cezar" <Cezar@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:E8548106-843F-4252-A39F-4C40BC63774B@dotnet.itags.org.microsoft.com...
> I am new to Web Forms and I ported my little app from Windows Forms to
> ASP.NET and I am wondering why some things are not working as before.
> Although I figured most of them, one of them is that on my form I have
input
> fields and a button causing to store all the input fields into the
database.
> However, when in the button OnClick event I gather all the form control
> values by either getting txtBox.Text or lstChoice.SelectedItem, all the
> values are not equal to the user choices, but to the values last set by
the
> form programatically on Form Load. It looks that I am missing some event
that
> sends the user control values from the client to the server.
> Am I missing something?
> Thank you
> Cezar Mart
>

0 comments:

Post a Comment