473,799 Members | 2,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override a posted form value

tmb
I have a page with many dynamically created HtmlSelect controls which
i create in the Page_Load function. Sometimes upon a post i need to
change the selected items in some of the controls depending on the
settings in other dynamic controls which is completely ok since i
create them myself. However, the problem is that this apparently gets
overridden by the form value that came with the postback. This is not
a setting handled by viewstate so turning off viewstate from the
control doesn't work.

My questions is: How do i override this behaviour? Is there some
function where i should do this or can i somehow manipulate the form
values used (they are read-only normally). Should i delay the creation
of the controls until viewstate and form values have been applied? If
so where do i do that and how?

Any help on this is appreciated.

Regards TMB

Feb 2 '07 #1
6 2269
Is this what you want?

if (!IsPostBack) {
}

Peter

<tm*@grislygrot to.comwrote in message
news:11******** **************@ a75g2000cwd.goo glegroups.com.. .
>I have a page with many dynamically created HtmlSelect controls which
i create in the Page_Load function. Sometimes upon a post i need to
change the selected items in some of the controls depending on the
settings in other dynamic controls which is completely ok since i
create them myself. However, the problem is that this apparently gets
overridden by the form value that came with the postback. This is not
a setting handled by viewstate so turning off viewstate from the
control doesn't work.

My questions is: How do i override this behaviour? Is there some
function where i should do this or can i somehow manipulate the form
values used (they are read-only normally). Should i delay the creation
of the controls until viewstate and form values have been applied? If
so where do i do that and how?

Any help on this is appreciated.

Regards TMB

Feb 2 '07 #2
tmb
Is this what you want?
>
if (!IsPostBack) {

}
No, it is a postback already. So the problem is that i want to change
values for a dynamic control that has values in the form coming in
from the postback. This is what happens:

In form:
Ctrl1.Value = 1, Ctrl2.Value = 1

On postback in Page_Load():
if ( Ctrl1.Value = 1 )
Ctrl2.Value = 2 <-- This action is ignored since the setting of the
value to 1 which was posted is done later in the chain overwriting my
2.

On display:
Ctrl1.Value = 1, Ctrl2.Value = 1

So what i need is a way of telling the control to ignore the posted
value or place the creation of the controls to after the form values
have been applied. Also, note that as mentioned this has nothing to do
with viewstate so setting it to false won't work.

Regards TMB

Feb 2 '07 #3
you should create the controls in oninit. then by form load the postback
values will be applied, and can be overridden.

-- bruce (sqlwork.com)

tm*@grislygrott o.com wrote:
I have a page with many dynamically created HtmlSelect controls which
i create in the Page_Load function. Sometimes upon a post i need to
change the selected items in some of the controls depending on the
settings in other dynamic controls which is completely ok since i
create them myself. However, the problem is that this apparently gets
overridden by the form value that came with the postback. This is not
a setting handled by viewstate so turning off viewstate from the
control doesn't work.

My questions is: How do i override this behaviour? Is there some
function where i should do this or can i somehow manipulate the form
values used (they are read-only normally). Should i delay the creation
of the controls until viewstate and form values have been applied? If
so where do i do that and how?

Any help on this is appreciated.

Regards TMB
Feb 2 '07 #4
tmb
On Feb 2, 5:30 pm, bruce barker <nos...@nospam. comwrote:
you should create the controls in oninit. then by form load the postback
values will be applied, and can be overridden.
Thanks on the input, Bruce. However, i'm unclear on how this will help
since the only thing i can see happening is that i create the controls
earlier in the process, ie in oninit instead of page_load and the form
values seems to be applied after page_load since they override my
settings done in page_load. Or do you mean if the control exists in
oninit and the values are set there the form values will not be
applied later?

Regards TMB

Feb 3 '07 #5
If you use ASP.NET 2.0, you can handle that at LoadComplete event (it
happens after all postback data etc is applied). Only issue is that postback
data is handled right after Load event, so your control instances would need
to exist at Load, if you still expect them to load the postback data
normally, but you can then override things at LoadComplete.

Overriding loading at single control level might need custom control
implementation.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
<tm*@grislygrot to.comwrote in message
news:11******** **************@ a75g2000cwd.goo glegroups.com.. .
>I have a page with many dynamically created HtmlSelect controls which
i create in the Page_Load function. Sometimes upon a post i need to
change the selected items in some of the controls depending on the
settings in other dynamic controls which is completely ok since i
create them myself. However, the problem is that this apparently gets
overridden by the form value that came with the postback. This is not
a setting handled by viewstate so turning off viewstate from the
control doesn't work.

My questions is: How do i override this behaviour? Is there some
function where i should do this or can i somehow manipulate the form
values used (they are read-only normally). Should i delay the creation
of the controls until viewstate and form values have been applied? If
so where do i do that and how?

Any help on this is appreciated.

Regards TMB
Feb 4 '07 #6
tmb
On Feb 4, 8:54 am, "Teemu Keiski" <jot...@aspalli ance.comwrote:
If you use ASP.NET 2.0, you can handle that at LoadComplete event (it
happens after all postback data etc is applied). Only issue is that postback
data is handled right after Load event, so your control instances would need
to exist at Load, if you still expect them to load the postback data
normally, but you can then override things at LoadComplete.

Overriding loading at single control level might need custom control
implementation.
Strange, i posted an answer and it said it was posted ok but i don't
see it... Oh well. here goes:

Thanks on the insight, Teemu. I never thought about LoadComplete. But
as you say last in your answer it would be better to override Load for
the separate controls instead as there might be many more controls on
the page which i don't want to sift through every post. I think i will
opt for that solution instead as it seems cleaner and i already handle
everything manually in the application. The code has been converted
from asp/vbscript so it doesn't handle the asp.net mechanisms so well.
I think i have my work cut out for me in this case as i also want to
make it more object oriented.

So thanks everybody for your help and be sure that i'll return with
more questions when i get stuck :D

Regards TMB

Feb 4 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5160
by: Kelly Domalik | last post by:
I would like to override the "disabled" property of a hidden field. When disabled is set to "true", it would call a function to disable 2 other text fields on the form. When disabled is set to "false", it would enable those 2 text fields. You should also be able to get the value of it as if it were a property: alert(my_hidden_field.disabled); Is there any way to do this? Many thanks to anyone that can help.
14
12150
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years namespace MyNamespac public delegate void MyDel() public class MyBase public virtual...
8
2897
by: JPRoot | last post by:
Hi M. Jeffrey Tan, Just hopping you didn't forget me? :) Thanks JPRoot ----- \"Jeffrey Tan\" wrote: -----
2
1330
by: Mark Essex | last post by:
I am trying to build an interface that requires the developer to use the OVERRIDE option. I looked at abstract classes, but seemed to have a couple of problems: 1. If you do this in a form, it appears that I can't get the designer to display the derived forms 2. It forces the override in the derived form (form A), but if another form (form B) derives from this derived form (form A), it isn't forced to override the method.
18
4856
by: bhavin | last post by:
Hi, Can someone point me to some good best practices kind of documentation on use of events compared to method overriding. Ex. In Windows Forms when should i have an event handler for Paint, and when should i override OnPaint? I have to implement added functionality in a child class, and am in two minds .. to have the parent fire an event, or make the method virtual and override in the child. Am hoping some reading with description of...
3
4266
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint of a subclassed DataGridTextBoxColum dos not seem like a practical way to do it. I have subclassed a DataGrid and overridden the OnPaint as such:
8
5499
by: bdeviled | last post by:
I am deploying to a web environment that uses load balancing and to insure that sessions persist across servers, the environment uses SQL to manage sessions. The machine.config file determines how all applications will use sessions and to insure that all application use this method, the session properties cannot be overriden. Within the sessionstate tags, the webadmin (upon my request)r emoved the property for timeout, hoping that...
2
2011
by: Jason Huang | last post by:
Hi, In my C# Windows form MyForm, it has a function MyFunction which is a big function and has lots of codes. I am thinking the override for MyFunction, one MyFunction has a parameter which will pass a value into the function, while the origin MyFunction doesn't pass that value. Now comes my question, since the MyFunction is a long function, is the "Override" for that function a good idea, or there're other better solutions?
52
3500
by: Jim Langston | last post by:
I wanted to do an operator override for but couldnt' figure out the syntax. I tried this (code that doesn't compile commented out with //: class CMyBitmap { public: CMyBitmap( int Rows, int Columns ): Rows_( Rows ), Columns_( Columns ) { Data_ = new SPixel; }
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.