Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Saturday, March 31, 2012

Storing/Retrieving Objects in the Session

I have a form set up currently so that when someone is added, an object is created with that persons information, and that object is then added to the Session. When the user is done with the form, I have the code setup to mirror the information back on a webpage (when I know it's spewing back the same information I put in, then I'll have it be stored in a database). The problem I am having is that I don't know how to call my toString method of my object from the session.
The class is called Person, and the object is called objPerson, I store it this way:

Session.Add("objPerson", objPerson)

and echo it back to the screen this way:

Response.Write(Session.Item("objPerson"))

The only thing that comes out is the name of the object though, with the namespaces ( COCO.objects.Person ). I tried using

Response.Write( Session.Item( "objPerson.toString()") )

But I had a feeling that wouldn't work, and it didn't. Have I approached this wrong, or am I on the right track here?
Thanks,
DSimmonHi there...

The problem is that you have to sat your item from the session to the Object type of that item, and then you can use it.

Assuming that the class of objPerson is "Person", you would have to do something like this to retreive it:

Person sessionPerson = (Person)Session("Person");

And then use 'sessionPerson' as you want to.

You can use it directly also like this:

((Person)Session("Person")).Name;

Again, assuming you have a "Name" for your "Person" class.

I hope this helps, let me know if you need more info.

Covo
Ahh, so I have to make a storage when I retrieve the object from the session, then recast it to that object type before I use it.
That makes sense, I'll try it now.
Thanks for you help.

David
you're welcome!

Notice that you don't have to make a storage object... If you see the second method I listed, you'll see that you can just cast the session to the object and use it directly.

Strange Behavior from RequiredFieldValidator (and Two LinkButtons)

We have an ASP.NET web form with 1 TextBox, 2 LinkButtons, and 1
RequireFieldValidator. The situation is: the user needs to enter a folder
name in the TextBox and click the first LinkButton (the Create Folder
LinkButton) to create the folder. Then once that's done, they need to click
the second LinkButton (the Next LinkButton) to go to the next page (a
rudimentary wizard).
The RequiredFieldValidator is there to make sure the user enters a folder
name in the TextBox before clicking the first LinkButton (the Create Folder
LinkButton). This all works fine.
What's strange is if the user doesn't enter anything in the TextBox and
clicks the second LinkButton (the Next LinkButton) before clicking the first
LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alarms
the error anyway.
Is this correct behavior? What we want is for the first LinkButton (the
Create Report LinkButton) only to validate that text has been entered in the
TextBox, not the second LinkButton (the Next LinkButton). How can we do
this?Hi JJ,
The function of the requiredfield validator is just to check the txtbox is
having some value or not.
If you want that checking has to be made only for the first link button and
not for the second link button, then specifically you have to inform the
validator as follows.
1. Click the second link button and go to the properties window.
2. Set the cause validation property to False.
So, here after when you are click second link button form will not do any
validations.
Hope this helps you.
Cheers,
Jerome. M
"JJ" wrote:

> We have an ASP.NET web form with 1 TextBox, 2 LinkButtons, and 1
> RequireFieldValidator. The situation is: the user needs to enter a folder
> name in the TextBox and click the first LinkButton (the Create Folder
> LinkButton) to create the folder. Then once that's done, they need to cli
ck
> the second LinkButton (the Next LinkButton) to go to the next page (a
> rudimentary wizard).
> The RequiredFieldValidator is there to make sure the user enters a folder
> name in the TextBox before clicking the first LinkButton (the Create Folde
r
> LinkButton). This all works fine.
> What's strange is if the user doesn't enter anything in the TextBox and
> clicks the second LinkButton (the Next LinkButton) before clicking the fir
st
> LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alar
ms
> the error anyway.
> Is this correct behavior? What we want is for the first LinkButton (the
> Create Report LinkButton) only to validate that text has been entered in t
he
> TextBox, not the second LinkButton (the Next LinkButton). How can we do
> this?
>
>

Strange Behavior from RequiredFieldValidator (and Two LinkButtons)

We have an ASP.NET web form with 1 TextBox, 2 LinkButtons, and 1
RequireFieldValidator. The situation is: the user needs to enter a folder
name in the TextBox and click the first LinkButton (the Create Folder
LinkButton) to create the folder. Then once that's done, they need to click
the second LinkButton (the Next LinkButton) to go to the next page (a
rudimentary wizard).

The RequiredFieldValidator is there to make sure the user enters a folder
name in the TextBox before clicking the first LinkButton (the Create Folder
LinkButton). This all works fine.

What's strange is if the user doesn't enter anything in the TextBox and
clicks the second LinkButton (the Next LinkButton) before clicking the first
LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alarms
the error anyway.

Is this correct behavior? What we want is for the first LinkButton (the
Create Report LinkButton) only to validate that text has been entered in the
TextBox, not the second LinkButton (the Next LinkButton). How can we do
this?Hi JJ,

The function of the requiredfield validator is just to check the txtbox is
having some value or not.

If you want that checking has to be made only for the first link button and
not for the second link button, then specifically you have to inform the
validator as follows.

1. Click the second link button and go to the properties window.

2. Set the cause validation property to False.

So, here after when you are click second link button form will not do any
validations.

Hope this helps you.

Cheers,

Jerome. M

"JJ" wrote:

> We have an ASP.NET web form with 1 TextBox, 2 LinkButtons, and 1
> RequireFieldValidator. The situation is: the user needs to enter a folder
> name in the TextBox and click the first LinkButton (the Create Folder
> LinkButton) to create the folder. Then once that's done, they need to click
> the second LinkButton (the Next LinkButton) to go to the next page (a
> rudimentary wizard).
> The RequiredFieldValidator is there to make sure the user enters a folder
> name in the TextBox before clicking the first LinkButton (the Create Folder
> LinkButton). This all works fine.
> What's strange is if the user doesn't enter anything in the TextBox and
> clicks the second LinkButton (the Next LinkButton) before clicking the first
> LinkButton (the Create Folder LinkButton), the RequiredFieldValidator alarms
> the error anyway.
> Is this correct behavior? What we want is for the first LinkButton (the
> Create Report LinkButton) only to validate that text has been entered in the
> TextBox, not the second LinkButton (the Next LinkButton). How can we do
> this?
>

Strange behavior with server web controls

Hi,

I don't know if anybody else experienced this, but sometimes, I can't set
breakpoints the event code of a button on a form for some reason. The code
still executes, but I can't stop the execution with a breakpoint. While
compiling, a question mark appears in the red dot on the left side of the
code editor and if I hover my mouse over it, it says

"The breakpoint will not currently be hit. No executable code is associated
with this line."

The last time I experienced this, I has to copy the event code somewhere
else, delete the form button and recreate it by pasting the code back.
Anybody had this happen to them? Is there an explanation?

Thanks

EricJust an idea...

Sometimes, VS.NET would erase everything after the Handles clause. Perhaps you
could see if that's the case.

I'm just speculating that the compiler is noticing that without a handler,
there's nothing to call the code.

Ken

"news.public.microsoft.com" <mindmover@.hotmail.com> wrote in message
news:eIU3lNWUDHA.372@.tk2msftngp13.phx.gbl...
Hi,

I don't know if anybody else experienced this, but sometimes, I can't set
breakpoints the event code of a button on a form for some reason. The code
still executes, but I can't stop the execution with a breakpoint. While
compiling, a question mark appears in the red dot on the left side of the
code editor and if I hover my mouse over it, it says

"The breakpoint will not currently be hit. No executable code is associated
with this line."

The last time I experienced this, I has to copy the event code somewhere
else, delete the form button and recreate it by pasting the code back.
Anybody had this happen to them? Is there an explanation?

Thanks

Eric

Wednesday, March 28, 2012

Strange Characters

Hello,
I have a form with a textbox.
When I click submit the text in the textbox changes.
For example "Andr=E9 Sousa" becomes "Andr=C3=A9 Sousa"
What is wrong and how can I solve this?
Thanks,
Miguel"shapper" <mdmoura@.gmail.com> wrote in message
news:1169488427.871757.44860@.s34g2000cwa.googlegroups.com...
For example "Andr Sousa" becomes "André Sousa"
Whenever one "unusual" character gets substitued by two even more "unusual"
characters, you can be pretty certain it's a Unicode encoding issue...
Post your code...

Strange Characters

Hello,

I have a form with a textbox.

When I click submit the text in the textbox changes.

For example "Andr Sousa" becomes "André Sousa"

What is wrong and how can I solve this?

Thanks,

Miguel"shapper" <mdmoura@.gmail.comwrote in message
news:1169488427.871757.44860@.s34g2000cwa.googlegro ups.com...

For example "Andr Sousa" becomes "André Sousa"

Whenever one "unusual" character gets substitued by two even more "unusual"
characters, you can be pretty certain it's a Unicode encoding issue...

Post your code...

Strange characters

Hello,

I have a form with a textbox.

When I click submit the text in the textbox changes.

For example "André Sousa" becomes "Andr?? Sousa"

What is wrong and how can I solve this?

Thanks,

Miguel

try use

Server.HtmlDecode
Server.HtmlEncode

see how it goes


Hi,

Can you show me your code, I am glad to check it in my computer for you.

Strange Characters in Asp.Net Text Box

Hello,

I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as "??áàéí" when I load the data again I get a few strange characters: "?§?£??? ???"

What is going wrong here?

How can I solve this?

Thanks,
Miguel

What encoding did you set for the pages? Set the responseEncoding to "utf-8"

Check this link on how to set it in the web.config filehttp://msdn2.microsoft.com/en-us/library/hy4kkhe0(vs.80).aspx

Thanks

Strange Characters in Asp.Net Text Box

Hello,
I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"=E7=E3=E1=E0=E9=ED" when I load the data again I get a few strange charact=
ers:
"=C3=A7=C3=A3=C3=A1=C3 =C3=A9=C3"
What is going wrong here?
How can I solve this?
Thanks,
MiguelHello shapper,
This seems like a flaw in Unicode encoding mode in your URL If the character
s
you have types are unicode, then make sure that you save the file in proper
Unicode mode. If you are using VS2005, then you will find a command 'Advance
d
Save Options' which does this.
Thanks
Cyril Gupta
-- You can do anything with a little bit of 'magination.
-- I've been programming so long, my brain is now software.

> Hello,
> I have a form which saves some data to an SQL 2005 database
> If the text written in the text box contains characters such as
> "" when I load the data again I get a few strange characters:
> "??á é"
> What is going wrong here?
> How can I solve this?
> Thanks,
> Miguel

Strange Characters in Asp.Net Text Box

Hello,

I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"" when I load the data again I get a few strange characters:
"??á é"

What is going wrong here?

How can I solve this?

Thanks,
MiguelHello shapper,

This seems like a flaw in Unicode encoding mode in your URL If the characters
you have types are unicode, then make sure that you save the file in proper
Unicode mode. If you are using VS2005, then you will find a command 'Advanced
Save Options' which does this.

Thanks
Cyril Gupta

-- You can do anything with a little bit of 'magination.

-- I've been programming so long, my brain is now software.

Quote:

Originally Posted by

Hello,
>
I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"" when I load the data again I get a few strange characters:
"??á é"
What is going wrong here?
>
How can I solve this?
>
Thanks,
Miguel

Saturday, March 24, 2012

Strange error in asp.net 1.1

I was working on a project in asp.net 1.1. I formatted my system & to save the project copied it to another drive in form of folder(which is stored in wwwroot directory). When i reinstalled windows & copied my project to wwwroot & tried running it in visual studio then following error came:

Web server is not configurd to debug the project. Please configure the web server.

Moreover when i use ' view in browser ' option then also it reports an error in web.config's authentication part.

What could be the possible reason and solution for this problem?

Make sure you have created the application as a valid application for the IIS ( virtual directory)

Thanks


Can u elaborate on that please. and what exactly i m supposed to do?

to create a virtual directory for your project

1- Right click My Computer/ select Manage.

2- Expand services and applications, expand Internet Information Services, Expand Website then Default Website.

3- right click your project folder, select properties, then click on "Create" beside the Application name

HC

Strange error, please

Hi. I have created a web-based "file manager", for remote-administration of
a web-site. It works okay.
The "main" form in the "file manager" is BrowseFiles.aspx. I can edit the
text files (among which the "js" files) by clicking on an achor which
redirects me to "edit.aspx".
Once in "edit.aspx", after I view a ".js" file, for instance, I click on the
button "Return to file manager". The code in the command "Return to file
manager" is mainly
Response.Redirect("BrowseFiles.aspx?Folder=" & strFolderPath) where
strFolderPath is the folder I was viewing before starting the edit.
I get:
________________________________________
___________________
Server Error in '/aspnetprojects/vsnet/ThePhile' Application.
A potentially dangerous Request.Form value was detected from the client
(txtFileContent="...uterHeight<screen.availHeight...").
Description: Request Validation has detected a potentially dangerous client
input value, and processing of the request has been aborted. This value may
indicate an attempt to compromise the security of your application, such as
a cross-site scripting attack. You can disable request validation by setting
validateRequest=false in the Page directive or in the configuration section.
However, it is strongly recommended that your application explicitly check
all inputs in this case.
Exception Details: System.Web.HttpRequestValidationException: A potentially
dangerous Request.Form value was detected from the client
(txtFileContent="...uterHeight<screen.availHeight...").
________________________________________
___________________
Note: txtFileContent is the text box in which I show the file to edit
(using, of course, stream readers).
I have tried using their suggestion (validateRequest=false) but it does not
change a thing... What am I doing wrong ?
Thank you.
Alex.The reason maybe the "<" or any html or script tag for that matter. Try it
again with a demo file which just contains "<foo>" or something and see if
you get the same error. Then try it with a file that has just "foo" and you
may not get any errors.
If this is the case then the way to fix it is to convert all < and > chars
to < and > when displaying to the client. You will then need to convert them
back again when receiving them.
The reason: Well the error report is telling you that the user has input a
script or script tag which could potentially be of harm. This is why most
forums etc do not accept HTML code from public users.
I could be wrong, but I hope it helps.
Regards
Geoff
"Alex Nitulescu" wrote:

> Hi. I have created a web-based "file manager", for remote-administration o
f
> a web-site. It works okay.
> The "main" form in the "file manager" is BrowseFiles.aspx. I can edit the
> text files (among which the "js" files) by clicking on an achor which
> redirects me to "edit.aspx".
> Once in "edit.aspx", after I view a ".js" file, for instance, I click on t
he
> button "Return to file manager". The code in the command "Return to file
> manager" is mainly
> Response.Redirect("BrowseFiles.aspx?Folder=" & strFolderPath) where
> strFolderPath is the folder I was viewing before starting the edit.
> I get:
> ________________________________________
___________________
> Server Error in '/aspnetprojects/vsnet/ThePhile' Application.
> A potentially dangerous Request.Form value was detected from the client
> (txtFileContent="...uterHeight<screen.availHeight...").
> Description: Request Validation has detected a potentially dangerous clien
t
> input value, and processing of the request has been aborted. This value ma
y
> indicate an attempt to compromise the security of your application, such a
s
> a cross-site scripting attack. You can disable request validation by setti
ng
> validateRequest=false in the Page directive or in the configuration sectio
n.
> However, it is strongly recommended that your application explicitly check
> all inputs in this case.
> Exception Details: System.Web.HttpRequestValidationException: A potentiall
y
> dangerous Request.Form value was detected from the client
> (txtFileContent="...uterHeight<screen.availHeight...").
> ________________________________________
___________________
> Note: txtFileContent is the text box in which I show the file to edit
> (using, of course, stream readers).
> I have tried using their suggestion (validateRequest=false) but it does no
t
> change a thing... What am I doing wrong ?
> Thank you.
> Alex.
>
>
Geoff, you were right - I tried a foo.html file, first containing "foo", and
second containing "<foo>". Obviously, the first time it worked, the second
time not.
I guess the only solution would be to convert those < and > to something
else - I'll have to find a convenient replacement symbol..
"Geoff Willings" <GeoffWillings@.discussions.microsoft.com> wrote in message
news:058EC81A-23FD-490B-8A8B-4968FB5681DD@.microsoft.com...
> The reason maybe the "<" or any html or script tag for that matter. Try it
> again with a demo file which just contains "<foo>" or something and see if
> you get the same error. Then try it with a file that has just "foo" and
> you
> may not get any errors.
> If this is the case then the way to fix it is to convert all < and > chars
> to < and > when displaying to the client. You will then need to convert
> them
> back again when receiving them.
> The reason: Well the error report is telling you that the user has input a
> script or script tag which could potentially be of harm. This is why most
> forums etc do not accept HTML code from public users.
> I could be wrong, but I hope it helps.
> Regards
> Geoff
> "Alex Nitulescu" wrote:
>

Strange error, please

Hi. I have created a web-based "file manager", for remote-administration of
a web-site. It works okay.

The "main" form in the "file manager" is BrowseFiles.aspx. I can edit the
text files (among which the "js" files) by clicking on an achor which
redirects me to "edit.aspx".

Once in "edit.aspx", after I view a ".js" file, for instance, I click on the
button "Return to file manager". The code in the command "Return to file
manager" is mainly
Response.Redirect("BrowseFiles.aspx?Folder=" & strFolderPath) where
strFolderPath is the folder I was viewing before starting the edit.

I get:
__________________________________________________ _________
Server Error in '/aspnetprojects/vsnet/ThePhile' Application.

A potentially dangerous Request.Form value was detected from the client
(txtFileContent="...uterHeight<screen.availHeight...").
Description: Request Validation has detected a potentially dangerous client
input value, and processing of the request has been aborted. This value may
indicate an attempt to compromise the security of your application, such as
a cross-site scripting attack. You can disable request validation by setting
validateRequest=false in the Page directive or in the configuration section.
However, it is strongly recommended that your application explicitly check
all inputs in this case.

Exception Details: System.Web.HttpRequestValidationException: A potentially
dangerous Request.Form value was detected from the client
(txtFileContent="...uterHeight<screen.availHeight...").
__________________________________________________ _________

Note: txtFileContent is the text box in which I show the file to edit
(using, of course, stream readers).

I have tried using their suggestion (validateRequest=false) but it does not
change a thing... What am I doing wrong ?

Thank you.
Alex.The reason maybe the "<" or any html or script tag for that matter. Try it
again with a demo file which just contains "<foo>" or something and see if
you get the same error. Then try it with a file that has just "foo" and you
may not get any errors.

If this is the case then the way to fix it is to convert all < and > chars
to < and > when displaying to the client. You will then need to convert them
back again when receiving them.

The reason: Well the error report is telling you that the user has input a
script or script tag which could potentially be of harm. This is why most
forums etc do not accept HTML code from public users.

I could be wrong, but I hope it helps.

Regards

Geoff

"Alex Nitulescu" wrote:

> Hi. I have created a web-based "file manager", for remote-administration of
> a web-site. It works okay.
> The "main" form in the "file manager" is BrowseFiles.aspx. I can edit the
> text files (among which the "js" files) by clicking on an achor which
> redirects me to "edit.aspx".
> Once in "edit.aspx", after I view a ".js" file, for instance, I click on the
> button "Return to file manager". The code in the command "Return to file
> manager" is mainly
> Response.Redirect("BrowseFiles.aspx?Folder=" & strFolderPath) where
> strFolderPath is the folder I was viewing before starting the edit.
> I get:
> __________________________________________________ _________
> Server Error in '/aspnetprojects/vsnet/ThePhile' Application.
> A potentially dangerous Request.Form value was detected from the client
> (txtFileContent="...uterHeight<screen.availHeight...").
> Description: Request Validation has detected a potentially dangerous client
> input value, and processing of the request has been aborted. This value may
> indicate an attempt to compromise the security of your application, such as
> a cross-site scripting attack. You can disable request validation by setting
> validateRequest=false in the Page directive or in the configuration section.
> However, it is strongly recommended that your application explicitly check
> all inputs in this case.
> Exception Details: System.Web.HttpRequestValidationException: A potentially
> dangerous Request.Form value was detected from the client
> (txtFileContent="...uterHeight<screen.availHeight...").
> __________________________________________________ _________
> Note: txtFileContent is the text box in which I show the file to edit
> (using, of course, stream readers).
> I have tried using their suggestion (validateRequest=false) but it does not
> change a thing... What am I doing wrong ?
> Thank you.
> Alex.
>
Geoff, you were right - I tried a foo.html file, first containing "foo", and
second containing "<foo>". Obviously, the first time it worked, the second
time not.
I guess the only solution would be to convert those < and > to something
else - I'll have to find a convenient replacement symbol..

"Geoff Willings" <GeoffWillings@.discussions.microsoft.com> wrote in message
news:058EC81A-23FD-490B-8A8B-4968FB5681DD@.microsoft.com...
> The reason maybe the "<" or any html or script tag for that matter. Try it
> again with a demo file which just contains "<foo>" or something and see if
> you get the same error. Then try it with a file that has just "foo" and
> you
> may not get any errors.
> If this is the case then the way to fix it is to convert all < and > chars
> to < and > when displaying to the client. You will then need to convert
> them
> back again when receiving them.
> The reason: Well the error report is telling you that the user has input a
> script or script tag which could potentially be of harm. This is why most
> forums etc do not accept HTML code from public users.
> I could be wrong, but I hope it helps.
> Regards
> Geoff
> "Alex Nitulescu" wrote:
>> Hi. I have created a web-based "file manager", for remote-administration
>> of
>> a web-site. It works okay.
>>
>> The "main" form in the "file manager" is BrowseFiles.aspx. I can edit the
>> text files (among which the "js" files) by clicking on an achor which
>> redirects me to "edit.aspx".
>>
>> Once in "edit.aspx", after I view a ".js" file, for instance, I click on
>> the
>> button "Return to file manager". The code in the command "Return to file
>> manager" is mainly
>> Response.Redirect("BrowseFiles.aspx?Folder=" & strFolderPath) where
>> strFolderPath is the folder I was viewing before starting the edit.
>>
>> I get:
>> __________________________________________________ _________
>> Server Error in '/aspnetprojects/vsnet/ThePhile' Application.
>>
>> A potentially dangerous Request.Form value was detected from the client
>> (txtFileContent="...uterHeight<screen.availHeight...").
>> Description: Request Validation has detected a potentially dangerous
>> client
>> input value, and processing of the request has been aborted. This value
>> may
>> indicate an attempt to compromise the security of your application, such
>> as
>> a cross-site scripting attack. You can disable request validation by
>> setting
>> validateRequest=false in the Page directive or in the configuration
>> section.
>> However, it is strongly recommended that your application explicitly
>> check
>> all inputs in this case.
>>
>> Exception Details: System.Web.HttpRequestValidationException: A
>> potentially
>> dangerous Request.Form value was detected from the client
>> (txtFileContent="...uterHeight<screen.availHeight...").
>> __________________________________________________ _________
>>
>> Note: txtFileContent is the text box in which I show the file to edit
>> (using, of course, stream readers).
>>
>> I have tried using their suggestion (validateRequest=false) but it does
>> not
>> change a thing... What am I doing wrong ?
>>
>> Thank you.
>> Alex.
>>
>>
>

Thursday, March 22, 2012

Strange Issue egarding ASP:textbox control.

I have a form. I fill the text property of all the textboxes on the form to
display information to the user. If the user changes a value and clicks
save. I save the information to the database.
This sounds all well and good however the record does not get updated, in
fact I have traced it to the fact that the textbox.text property is not
being updated after the user changes the value.
Please, if you have experienced anything like this, please help. This is
very frustrating.That's not much information to go on but I suggest looking for something in
your onload that is rebinding or reloading the textbox with the original
data before you get to the click event of your save button. Remember that
onload is called before the button event.
Also, make sure you're only setting the value of the textbox from the
database when IsPostBack is false. If you're setting it in every case, you
will reset it before you get to the click event.
Good luck,
Dale
"Red" <wreyes@.optonline.net> wrote in message
news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> I have a form. I fill the text property of all the textboxes on the form
to
> display information to the user. If the user changes a value and clicks
> save. I save the information to the database.
> This sounds all well and good however the record does not get updated, in
> fact I have traced it to the fact that the textbox.text property is not
> being updated after the user changes the value.
> Please, if you have experienced anything like this, please help. This is
> very frustrating.
>
Hey thanks alot. I can not beleive I made such a simple mistake. For days I
have been looking at everything accept for when I was displaying the data.
Anyway, thanks again.
"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:e05xBXNUEHA.2564@.TK2MSFTNGP11.phx.gbl...
> That's not much information to go on but I suggest looking for something
in
> your onload that is rebinding or reloading the textbox with the original
> data before you get to the click event of your save button. Remember that
> onload is called before the button event.
> Also, make sure you're only setting the value of the textbox from the
> database when IsPostBack is false. If you're setting it in every case,
you
> will reset it before you get to the click event.
> Good luck,
> Dale
> "Red" <wreyes@.optonline.net> wrote in message
> news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> to
in
>

Strange Issue egarding ASP:textbox control.

I have a form. I fill the text property of all the textboxes on the form to
display information to the user. If the user changes a value and clicks
save. I save the information to the database.

This sounds all well and good however the record does not get updated, in
fact I have traced it to the fact that the textbox.text property is not
being updated after the user changes the value.

Please, if you have experienced anything like this, please help. This is
very frustrating.That's not much information to go on but I suggest looking for something in
your onload that is rebinding or reloading the textbox with the original
data before you get to the click event of your save button. Remember that
onload is called before the button event.

Also, make sure you're only setting the value of the textbox from the
database when IsPostBack is false. If you're setting it in every case, you
will reset it before you get to the click event.

Good luck,

Dale

"Red" <wreyes@.optonline.net> wrote in message
news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> I have a form. I fill the text property of all the textboxes on the form
to
> display information to the user. If the user changes a value and clicks
> save. I save the information to the database.
> This sounds all well and good however the record does not get updated, in
> fact I have traced it to the fact that the textbox.text property is not
> being updated after the user changes the value.
> Please, if you have experienced anything like this, please help. This is
> very frustrating.
Hey thanks alot. I can not beleive I made such a simple mistake. For days I
have been looking at everything accept for when I was displaying the data.

Anyway, thanks again.

"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:e05xBXNUEHA.2564@.TK2MSFTNGP11.phx.gbl...
> That's not much information to go on but I suggest looking for something
in
> your onload that is rebinding or reloading the textbox with the original
> data before you get to the click event of your save button. Remember that
> onload is called before the button event.
> Also, make sure you're only setting the value of the textbox from the
> database when IsPostBack is false. If you're setting it in every case,
you
> will reset it before you get to the click event.
> Good luck,
> Dale
> "Red" <wreyes@.optonline.net> wrote in message
> news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> > I have a form. I fill the text property of all the textboxes on the form
> to
> > display information to the user. If the user changes a value and clicks
> > save. I save the information to the database.
> > This sounds all well and good however the record does not get updated,
in
> > fact I have traced it to the fact that the textbox.text property is not
> > being updated after the user changes the value.
> > Please, if you have experienced anything like this, please help. This is
> > very frustrating.

Strange issue with textbox

All

Have a form with 6 textboxes.

3 of these have a white background but for some strage
reason the 3 others are yellow, I cannot for the life of
me find out why the other 3 are yellow backgrounded.

This is a "copied" layout of the form,

Thanks in advanceHave you installed the Google Toolbar by any chance?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yop@.oceanfree.net> wrote in message
news:06df01c367f5$0fb4c720$a001280a@.phx.gbl...
> All
> Have a form with 6 textboxes.
> 3 of these have a white background but for some strage
> reason the 3 others are yellow, I cannot for the life of
> me find out why the other 3 are yellow backgrounded.
> This is a "copied" layout of the form,
> Thanks in advance
Kevin

I have alright! :)

>--Original Message--
>Have you installed the Google Toolbar by any chance?
>--
>HTH,
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>The more I learn, the less I know.
>"yop" <yop@.oceanfree.net> wrote in message
>news:06df01c367f5$0fb4c720$a001280a@.phx.gbl...
>> All
>>
>> Have a form with 6 textboxes.
>>
>> 3 of these have a white background but for some strage
>> reason the 3 others are yellow, I cannot for the life
of
>> me find out why the other 3 are yellow backgrounded.
>>
>> This is a "copied" layout of the form,
>>
>> Thanks in advance
>
>.
There you go!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yop@.oceanfree.net> wrote in message
news:0ea801c367ff$e0e94050$a501280a@.phx.gbl...
> Kevin
> I have alright! :)
>
> >--Original Message--
> >Have you installed the Google Toolbar by any chance?
> >--
> >HTH,
> >Kevin Spencer
> >Microsoft MVP
> >..Net Developer
> >http://www.takempis.com
> >The more I learn, the less I know.
> >"yop" <yop@.oceanfree.net> wrote in message
> >news:06df01c367f5$0fb4c720$a001280a@.phx.gbl...
> >> All
> >>
> >> Have a form with 6 textboxes.
> >>
> >> 3 of these have a white background but for some strage
> >> reason the 3 others are yellow, I cannot for the life
> of
> >> me find out why the other 3 are yellow backgrounded.
> >>
> >> This is a "copied" layout of the form,
> >>
> >> Thanks in advance
> >.
Thanks Kevin

that was it alright!

>--Original Message--
>There you go!
>--
>HTH,
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>The more I learn, the less I know.
>"yop" <yop@.oceanfree.net> wrote in message
>news:0ea801c367ff$e0e94050$a501280a@.phx.gbl...
>> Kevin
>>
>> I have alright! :)
>>
>>
>> >--Original Message--
>> >Have you installed the Google Toolbar by any chance?
>>> >--
>> >HTH,
>>> >Kevin Spencer
>> >Microsoft MVP
>> >..Net Developer
>> >http://www.takempis.com
>> >The more I learn, the less I know.
>>> >"yop" <yop@.oceanfree.net> wrote in message
>> >news:06df01c367f5$0fb4c720$a001280a@.phx.gbl...
>> >> All
>> >>
>> >> Have a form with 6 textboxes.
>> >>
>> >> 3 of these have a white background but for some
strage
>> >> reason the 3 others are yellow, I cannot for the
life
>> of
>> >> me find out why the other 3 are yellow backgrounded.
>> >>
>> >> This is a "copied" layout of the form,
>> >>
>> >> Thanks in advance
>>>> >.
>>
>.

Tuesday, March 13, 2012

strange postback problem

I have a form with a Submit button. The user fills out the form,
clicks the submit button, and then the page posts back to itself.
Every time the page posts back to itself, the "Page_Load" event fires.
So if the user first types the URL of the page in the browser, the
"Page_Load" event fires. Then he hits submit, and the form contents
are posted back, so the "Page_Load" event fires again. The form
appears again (I clear its contents), and he can fill it again, click
submit, and the "Page_Load" event fires again.
I also have a validator control that gives an error message if the user
leaves a field blank. So if the user clicks submit without filling in
a field, the submit code checks "If Page.IsValid()" and puts an error
message on the page. I find that the "Page_Load" event is fired for
this too. In other words, if the form is incorrect and the user clicks
submit, the "Page_Load" event fires, probably just to put the error
message on the page.
Now in the Page_Load event, I want to store the form's contents in a
database. To do that, I have to know why Page_Load is firing. I don't
want to store the form contents if Page.IsPostBack is False, because
that means this is the first time the page is viewed, and the form
hasn't been filled out yet. I also don't want to store the form
contents if there is an error on the page, even though Page_Load is
fired in this case as well.
So I thought the easy way to to this would be to create a Session
variable that tells me if the submit button found the form fields to be
valid. The submit code would look like this:
''
Sub SubmitClick(objSender As Object, objArgs As EventArgs)
If Page.IsValid() Then
LabDiagnostic.Text = "IS VALID"
Session("Valid") = True
Else
LabDiagnostic.Text = "NOT VALID"
Session("Valid") = False
End If
If Session("Valid") = True Then
LabDiagnostic2.Text = "Session('Valid') = True"
Else
LabDiagnostic2.Text = "Session('Valid') = False"
End If
End Sub
Notice that I put in Diagnostics just to be sure the code is working.
The diagnostics do show that it works.
Then in the "Page_Load" event, I test Session("Valid") again:
''''
Sub Page_Load(Source As Object, E As EventArgs)

If Page.IsPostBack Then
If Session("Valid") = True Then
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
Else
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
End If
End If
End Sub
''
But this time the diagnostic gives the opposite result than I expect!
This is so strange that I feel I must be doing something obviously
wrong, but I can't tell what it is.
Here is the entire code of the page, in case someone wants to try it
out:
-- Thanks
-- Marvin

<%@dotnet.itags.org.Page Language="VB" debug="true" %>
<%@dotnet.itags.org.Import NameSpace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %
<HTML>
<HEAD>
<TITLE>Enter Passenger Details</TITLE>
</HEAD
<script language="VB" runat="server">
''''
Sub Page_Load(Source As Object, E As EventArgs)

If Page.IsPostBack Then
If Session("Valid") = True Then
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
Else
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
End If
End If
End Sub
''
Sub SubmitClick(objSender As Object, objArgs As EventArgs)
If Page.IsValid() Then
LabDiagnostic.Text = "IS VALID"
Session("Valid") = True
Else
LabDiagnostic.Text = "NOT VALID"
Session("Valid") = False
End If
If Session("Valid") = True Then
LabDiagnostic2.Text = "Session('Valid') = True"
Else
LabDiagnostic2.Text = "Session('Valid') = False"
End If
End Sub
'' ''
</script
<BODY>
<form METHOD="POST" name="MyForm" runat="server">
<ASP:Label id="LabDiagnostic" runat="server" />
<hr>
<ASP:Label id="LabDiagnostic2" runat="server" />
<hr>
<ASP:Label id="LabDiagnostic3" runat="server" />
<center>
<table border="1">
<tr>
<td align="right">First Name</td>
<td><ASP:Textbox id="FirstName" MaxLength="40" Columns="40"
runat="server" />
<ASP:RequiredFieldValidator id="rfvFirstName" runat="server"
ControlToValidate="FirstName"
ErrorMessage="* You must enter a first name."
Display="dynamic">
*
</ASP:RequiredFieldValidator
</td>
</tr>
<tr><td align="center" colspan="2">
<asp:Button id="MyButton" Text="Submit" runat="server"
OnClick="SubmitClick" />
</td></tr
</table>
</center>
<center>
<table><tr><td>
<ASP:ValidationSummary id="valSummary" runat="server"
HeaderText = "<b>The following errors were found:</b>"
DisplayMode="List" ShowSummary="True" ShowMessageBox="True" />
<!-- normally I have ShowSummary="False" -->
</td></tr></table>
</center>
</form>
</BODY>
</HTMLThe Page_Load event allways fires. When the page loads off it goes, every
time, no exception.

> Now in the Page_Load event, I want to store the form's contents in a
> database. To do that, I have to know why Page_Load is firing. I don't
> want to store the form contents if Page.IsPostBack is False, because
> that means this is the first time the page is viewed, and the form
> hasn't been filled out yet. I also don't want to store the form
> contents if there is an error on the page, even though Page_Load is
> fired in this case as well.
> So I thought the easy way to to this would be to create a Session
> variable that tells me if the submit button found the form fields to be
> valid. The submit code would look like this:

This is not that difficult really. The validators which operate client side
are your first attempt at ensuring that the data is consistant with what you
would like the user to do with it. The validators on the client side will
stop form submission if there criteria is not met.

When the page loads you can test to see if it is a postback and then further
validate from there.

if Page.IsPostback Then

if MyValidationFunction() Then

'Store My Data

Else

litMessage.Text = "Your form has an error on it . . . Blah Blah Blah "

End If

End If

--
Best Regards

The Inimitable Mr Newbie
"COHENMARVIN" <cohenmarvin@.hotmail.com> wrote in message
news:1131192470.623229.323670@.g49g2000cwa.googlegr oups.com...
>I have a form with a Submit button. The user fills out the form,
> clicks the submit button, and then the page posts back to itself.
> Every time the page posts back to itself, the "Page_Load" event fires.
> So if the user first types the URL of the page in the browser, the
> "Page_Load" event fires. Then he hits submit, and the form contents
> are posted back, so the "Page_Load" event fires again. The form
> appears again (I clear its contents), and he can fill it again, click
> submit, and the "Page_Load" event fires again.
> I also have a validator control that gives an error message if the user
> leaves a field blank. So if the user clicks submit without filling in
> a field, the submit code checks "If Page.IsValid()" and puts an error
> message on the page. I find that the "Page_Load" event is fired for
> this too. In other words, if the form is incorrect and the user clicks
> submit, the "Page_Load" event fires, probably just to put the error
> message on the page.
> Now in the Page_Load event, I want to store the form's contents in a
> database. To do that, I have to know why Page_Load is firing. I don't
> want to store the form contents if Page.IsPostBack is False, because
> that means this is the first time the page is viewed, and the form
> hasn't been filled out yet. I also don't want to store the form
> contents if there is an error on the page, even though Page_Load is
> fired in this case as well.
> So I thought the easy way to to this would be to create a Session
> variable that tells me if the submit button found the form fields to be
> valid. The submit code would look like this:
> ''
> Sub SubmitClick(objSender As Object, objArgs As EventArgs)
> If Page.IsValid() Then
> LabDiagnostic.Text = "IS VALID"
> Session("Valid") = True
> Else
> LabDiagnostic.Text = "NOT VALID"
> Session("Valid") = False
> End If
> If Session("Valid") = True Then
> LabDiagnostic2.Text = "Session('Valid') = True"
> Else
> LabDiagnostic2.Text = "Session('Valid') = False"
> End If
> End Sub
> Notice that I put in Diagnostics just to be sure the code is working.
> The diagnostics do show that it works.
> Then in the "Page_Load" event, I test Session("Valid") again:
> ''''
> Sub Page_Load(Source As Object, E As EventArgs)
> If Page.IsPostBack Then
> If Session("Valid") = True Then
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
> Else
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
> End If
> End If
> End Sub
> ''
> But this time the diagnostic gives the opposite result than I expect!
> This is so strange that I feel I must be doing something obviously
> wrong, but I can't tell what it is.
> Here is the entire code of the page, in case someone wants to try it
> out:
> -- Thanks
> -- Marvin
> <%@.Page Language="VB" debug="true" %>
> <%@.Import NameSpace="System.Data" %>
> <%@. Import Namespace="System.Data.SqlClient" %>
> <HTML>
> <HEAD>
> <TITLE>Enter Passenger Details</TITLE>
> </HEAD>
> <script language="VB" runat="server">
> ''''
> Sub Page_Load(Source As Object, E As EventArgs)
> If Page.IsPostBack Then
> If Session("Valid") = True Then
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
> Else
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
> End If
> End If
> End Sub
> ''
> Sub SubmitClick(objSender As Object, objArgs As EventArgs)
> If Page.IsValid() Then
> LabDiagnostic.Text = "IS VALID"
> Session("Valid") = True
> Else
> LabDiagnostic.Text = "NOT VALID"
> Session("Valid") = False
> End If
> If Session("Valid") = True Then
> LabDiagnostic2.Text = "Session('Valid') = True"
> Else
> LabDiagnostic2.Text = "Session('Valid') = False"
> End If
> End Sub
> '' ''
> </script>
> <BODY>
> <form METHOD="POST" name="MyForm" runat="server">
> <ASP:Label id="LabDiagnostic" runat="server" />
> <hr>
> <ASP:Label id="LabDiagnostic2" runat="server" />
> <hr>
> <ASP:Label id="LabDiagnostic3" runat="server" />
> <center>
> <table border="1">
> <tr>
> <td align="right">First Name</td>
> <td><ASP:Textbox id="FirstName" MaxLength="40" Columns="40"
> runat="server" />
> <ASP:RequiredFieldValidator id="rfvFirstName" runat="server"
> ControlToValidate="FirstName"
> ErrorMessage="* You must enter a first name."
> Display="dynamic">
> *
> </ASP:RequiredFieldValidator>
> </td>
> </tr>
> <tr><td align="center" colspan="2">
> <asp:Button id="MyButton" Text="Submit" runat="server"
> OnClick="SubmitClick" />
> </td></tr>
> </table>
> </center>
> <center>
> <table><tr><td>
> <ASP:ValidationSummary id="valSummary" runat="server"
> HeaderText = "<b>The following errors were found:</b>"
> DisplayMode="List" ShowSummary="True" ShowMessageBox="True" />
> <!-- normally I have ShowSummary="False" -->
> </td></tr></table>
> </center>
> </form>
> </BODY>
> </HTML
It seems that my problem was that I assumed the "Submit" button fires
its event before the "Page_Load" event. I had a form with a "Submit"
button, and I thought that when I clicked the "submit" button, the
first thing that would happen was that the code in the "submit" button
event would be executed, and only after that would a "Page_Load" be
executed. But the converse is true, when you click a "submit" button,
the first thing that happens is a "Page_Load", and only after that does
the server execute the code of the "submit" button event.
This is true using the "OnClick" event, the "OnServerClick" event
appears to be radically different, I don't know why.
-- Marvin

strange postback problem

I have a form with a Submit button. The user fills out the form,
clicks the submit button, and then the page posts back to itself.
Every time the page posts back to itself, the "Page_Load" event fires.
So if the user first types the URL of the page in the browser, the
"Page_Load" event fires. Then he hits submit, and the form contents
are posted back, so the "Page_Load" event fires again. The form
appears again (I clear its contents), and he can fill it again, click
submit, and the "Page_Load" event fires again.
I also have a validator control that gives an error message if the user
leaves a field blank. So if the user clicks submit without filling in
a field, the submit code checks "If Page.IsValid()" and puts an error
message on the page. I find that the "Page_Load" event is fired for
this too. In other words, if the form is incorrect and the user clicks
submit, the "Page_Load" event fires, probably just to put the error
message on the page.
Now in the Page_Load event, I want to store the form's contents in a
database. To do that, I have to know why Page_Load is firing. I don't
want to store the form contents if Page.IsPostBack is False, because
that means this is the first time the page is viewed, and the form
hasn't been filled out yet. I also don't want to store the form
contents if there is an error on the page, even though Page_Load is
fired in this case as well.
So I thought the easy way to to this would be to create a Session
variable that tells me if the submit button found the form fields to be
valid. The submit code would look like this:
''
Sub SubmitClick(objSender As Object, objArgs As EventArgs)
If Page.IsValid() Then
LabDiagnostic.Text = "IS VALID"
Session("Valid") = True
Else
LabDiagnostic.Text = "NOT VALID"
Session("Valid") = False
End If
If Session("Valid") = True Then
LabDiagnostic2.Text = "Session('Valid') = True"
Else
LabDiagnostic2.Text = "Session('Valid') = False"
End If
End Sub
Notice that I put in Diagnostics just to be sure the code is working.
The diagnostics do show that it works.
Then in the "Page_Load" event, I test Session("Valid") again:
''''
Sub Page_Load(Source As Object, E As EventArgs)
If Page.IsPostBack Then
If Session("Valid") = True Then
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
Else
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
End If
End If
End Sub
''''
'''
But this time the diagnostic gives the opposite result than I expect!
This is so strange that I feel I must be doing something obviously
wrong, but I can't tell what it is.
Here is the entire code of the page, in case someone wants to try it
out:
-- Thanks
-- Marvin
<%@dotnet.itags.org.Page Language="VB" debug="true" %>
<%@dotnet.itags.org.Import NameSpace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<TITLE>Enter Passenger Details</TITLE>
</HEAD>
<script language="VB" runat="server">
''''
Sub Page_Load(Source As Object, E As EventArgs)
If Page.IsPostBack Then
If Session("Valid") = True Then
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
Else
LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
End If
End If
End Sub
''
Sub SubmitClick(objSender As Object, objArgs As EventArgs)
If Page.IsValid() Then
LabDiagnostic.Text = "IS VALID"
Session("Valid") = True
Else
LabDiagnostic.Text = "NOT VALID"
Session("Valid") = False
End If
If Session("Valid") = True Then
LabDiagnostic2.Text = "Session('Valid') = True"
Else
LabDiagnostic2.Text = "Session('Valid') = False"
End If
End Sub
''''
''
</script>
<BODY>
<form METHOD="POST" name="MyForm" runat="server">
<ASP:Label id="LabDiagnostic" runat="server" />
<hr>
<ASP:Label id="LabDiagnostic2" runat="server" />
<hr>
<ASP:Label id="LabDiagnostic3" runat="server" />
<center>
<table border="1">
<tr>
<td>First Name</td>
<td><ASP:Textbox id="FirstName" MaxLength="40" Columns="40"
runat="server" />
<ASP:RequiredFieldValidator id="rfvFirstName" runat="server"
ControlToValidate="FirstName"
ErrorMessage="* You must enter a first name."
Display="dynamic">
*
</ASP:RequiredFieldValidator>
</td>
</tr>
<tr><td align="center" colspan="2">
<asp:Button id="MyButton" Text="Submit" runat="server"
OnClick="SubmitClick" />
</td></tr>
</table>
</center>
<center>
<table><tr><td>
<ASP:ValidationSummary id="valSummary" runat="server"
HeaderText = "<b>The following errors were found:</b>"
DisplayMode="List" ShowSummary="True" ShowMessageBox="True" />
<!-- normally I have ShowSummary="False" -->
</td></tr></table>
</center>
</form>
</BODY>
</HTML>The Page_Load event allways fires. When the page loads off it goes, every
time, no exception.

> Now in the Page_Load event, I want to store the form's contents in a
> database. To do that, I have to know why Page_Load is firing. I don't
> want to store the form contents if Page.IsPostBack is False, because
> that means this is the first time the page is viewed, and the form
> hasn't been filled out yet. I also don't want to store the form
> contents if there is an error on the page, even though Page_Load is
> fired in this case as well.
> So I thought the easy way to to this would be to create a Session
> variable that tells me if the submit button found the form fields to be
> valid. The submit code would look like this:
This is not that difficult really. The validators which operate client side
are your first attempt at ensuring that the data is consistant with what you
would like the user to do with it. The validators on the client side will
stop form submission if there criteria is not met.
When the page loads you can test to see if it is a postback and then further
validate from there.
if Page.IsPostback Then
if MyValidationFunction() Then
'Store My Data
Else
litMessage.Text = "Your form has an error on it . . . Blah Blah Blah "
End If
End If
Best Regards
The Inimitable Mr Newbie
"COHENMARVIN" <cohenmarvin@.hotmail.com> wrote in message
news:1131192470.623229.323670@.g49g2000cwa.googlegroups.com...
>I have a form with a Submit button. The user fills out the form,
> clicks the submit button, and then the page posts back to itself.
> Every time the page posts back to itself, the "Page_Load" event fires.
> So if the user first types the URL of the page in the browser, the
> "Page_Load" event fires. Then he hits submit, and the form contents
> are posted back, so the "Page_Load" event fires again. The form
> appears again (I clear its contents), and he can fill it again, click
> submit, and the "Page_Load" event fires again.
> I also have a validator control that gives an error message if the user
> leaves a field blank. So if the user clicks submit without filling in
> a field, the submit code checks "If Page.IsValid()" and puts an error
> message on the page. I find that the "Page_Load" event is fired for
> this too. In other words, if the form is incorrect and the user clicks
> submit, the "Page_Load" event fires, probably just to put the error
> message on the page.
> Now in the Page_Load event, I want to store the form's contents in a
> database. To do that, I have to know why Page_Load is firing. I don't
> want to store the form contents if Page.IsPostBack is False, because
> that means this is the first time the page is viewed, and the form
> hasn't been filled out yet. I also don't want to store the form
> contents if there is an error on the page, even though Page_Load is
> fired in this case as well.
> So I thought the easy way to to this would be to create a Session
> variable that tells me if the submit button found the form fields to be
> valid. The submit code would look like this:
> ''
> Sub SubmitClick(objSender As Object, objArgs As EventArgs)
> If Page.IsValid() Then
> LabDiagnostic.Text = "IS VALID"
> Session("Valid") = True
> Else
> LabDiagnostic.Text = "NOT VALID"
> Session("Valid") = False
> End If
> If Session("Valid") = True Then
> LabDiagnostic2.Text = "Session('Valid') = True"
> Else
> LabDiagnostic2.Text = "Session('Valid') = False"
> End If
> End Sub
> Notice that I put in Diagnostics just to be sure the code is working.
> The diagnostics do show that it works.
> Then in the "Page_Load" event, I test Session("Valid") again:
> ''''
> Sub Page_Load(Source As Object, E As EventArgs)
> If Page.IsPostBack Then
> If Session("Valid") = True Then
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
> Else
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
> End If
> End If
> End Sub
> ''''
'''
> But this time the diagnostic gives the opposite result than I expect!
> This is so strange that I feel I must be doing something obviously
> wrong, but I can't tell what it is.
> Here is the entire code of the page, in case someone wants to try it
> out:
> -- Thanks
> -- Marvin
> <%@.Page Language="VB" debug="true" %>
> <%@.Import NameSpace="System.Data" %>
> <%@. Import Namespace="System.Data.SqlClient" %>
> <HTML>
> <HEAD>
> <TITLE>Enter Passenger Details</TITLE>
> </HEAD>
> <script language="VB" runat="server">
> ''''
> Sub Page_Load(Source As Object, E As EventArgs)
> If Page.IsPostBack Then
> If Session("Valid") = True Then
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = True"
> Else
> LabDiagnostic3.Text = "PAGE_LOAD: Session('Valid') = False"
> End If
> End If
> End Sub
> ''
> Sub SubmitClick(objSender As Object, objArgs As EventArgs)
> If Page.IsValid() Then
> LabDiagnostic.Text = "IS VALID"
> Session("Valid") = True
> Else
> LabDiagnostic.Text = "NOT VALID"
> Session("Valid") = False
> End If
> If Session("Valid") = True Then
> LabDiagnostic2.Text = "Session('Valid') = True"
> Else
> LabDiagnostic2.Text = "Session('Valid') = False"
> End If
> End Sub
> ''''
''
> </script>
> <BODY>
> <form METHOD="POST" name="MyForm" runat="server">
> <ASP:Label id="LabDiagnostic" runat="server" />
> <hr>
> <ASP:Label id="LabDiagnostic2" runat="server" />
> <hr>
> <ASP:Label id="LabDiagnostic3" runat="server" />
> <center>
> <table border="1">
> <tr>
> <td>First Name</td>
> <td><ASP:Textbox id="FirstName" MaxLength="40" Columns="40"
> runat="server" />
> <ASP:RequiredFieldValidator id="rfvFirstName" runat="server"
> ControlToValidate="FirstName"
> ErrorMessage="* You must enter a first name."
> Display="dynamic">
> *
> </ASP:RequiredFieldValidator>
> </td>
> </tr>
> <tr><td align="center" colspan="2">
> <asp:Button id="MyButton" Text="Submit" runat="server"
> OnClick="SubmitClick" />
> </td></tr>
> </table>
> </center>
> <center>
> <table><tr><td>
> <ASP:ValidationSummary id="valSummary" runat="server"
> HeaderText = "<b>The following errors were found:</b>"
> DisplayMode="List" ShowSummary="True" ShowMessageBox="True" />
> <!-- normally I have ShowSummary="False" -->
> </td></tr></table>
> </center>
> </form>
> </BODY>
> </HTML>
>
It seems that my problem was that I assumed the "Submit" button fires
its event before the "Page_Load" event. I had a form with a "Submit"
button, and I thought that when I clicked the "submit" button, the
first thing that would happen was that the code in the "submit" button
event would be executed, and only after that would a "Page_Load" be
executed. But the converse is true, when you click a "submit" button,
the first thing that happens is a "Page_Load", and only after that does
the server execute the code of the "submit" button event.
This is true using the "OnClick" event, the "OnServerClick" event
appears to be radically different, I don't know why.
-- Marvin

Strange problem

I Have a strange problem. I have build a form in wich are some controls. Two textbox and one dropdown control.
The user can perform a search selecting a value in dropdown or inserting in textbox and click on search button.
My sub verify if dropdown control or textbox changed and build sql string.
But the strange think is that all run only when I use dropdown. If I insert value in textbox and not dropdown search don't work.
The code don't run. Why?
I have inserted OnTextChanged event in textbox html code and OnSelectedIndexChanged in dropdown html code but nothing to do!
HELP ME, PLEASE!You need to post your code so we can help you.