Extending ASP.net Controls to provide status change

I was thinking about a couple things….yea i know “max you think?!?!?’

Did you know that the RaisePostDataChanged event is called after all your Load events are called, and this is right before Your postback event is called. This is so that you cant muck up your data on page_load() before it gets to your lets say Textbox.Click event.

Why is this help full to us, well this means that on page load or pre init we can see if the control has changed since its last postback. How?

Well you can still get to the new data from the Request object using the controls ClientID.

You can to this by Request.ServerVariables[Control.ControlID]

so we can create a method like:

public bool hasChanged(TextBox ctr)
{
return Request[Control.ControlID].Equals(ctr.Text);
}

its just the simple and we can subclass any control and do that.
we could also save the original loading value into viewstate.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *