469,601 Members | 2,344 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

Check Form controls have changed

Hello, I have a asp.net page with a form with 15 textboxes and a
couple of dropdownlists....I want to know if their is a way
(...serverside please...) of checking if any change has been made to
any of these controls before I send and update to the database....I
would rather not have a OnTextChanged & OnSelectedItemChanged with
postback set to false for every control on the page...

I have been trying to implement the IPostBackEventHandler in the page
System.Web.UI.Page, IPostBackEventHandler

and then override methods in it, but I think this is mostly for
customcontrols

public override void RaisePostBackEvent( IPostBackEventHandler
sourceControl, string eventArgument)
{
Response.Write( "<b>This is the RaisePostBackEvent event.</b><br>" );
}

public virtual void RaisePostDataChangedEvent()
{
Response.Write( "<b>This is the RaisePostDataChangedEvent");
}

public virtual bool LoadPostData(string postDataKey,
NameValueCollection postCollection)
{
string presentValue = _text;
string postedValue = postCollection[postDataKey];

if (!presentValue.Equals(postedValue))
{
_text = postedValue;
return true;
}
return false;
}
Nov 19 '05 #1
2 1361
You could save the original value as a custom attribute and later retrieve
it to compare with what was posted back.
Hope this helps.
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...
Hello, I have a asp.net page with a form with 15 textboxes and a
couple of dropdownlists....I want to know if their is a way
(...serverside please...) of checking if any change has been made to
any of these controls before I send and update to the database....I
would rather not have a OnTextChanged & OnSelectedItemChanged with
postback set to false for every control on the page...

I have been trying to implement the IPostBackEventHandler in the page
System.Web.UI.Page, IPostBackEventHandler

and then override methods in it, but I think this is mostly for
customcontrols

public override void RaisePostBackEvent( IPostBackEventHandler
sourceControl, string eventArgument)
{
Response.Write( "<b>This is the RaisePostBackEvent event.</b><br>" );
}

public virtual void RaisePostDataChangedEvent()
{
Response.Write( "<b>This is the RaisePostDataChangedEvent");
}

public virtual bool LoadPostData(string postDataKey,
NameValueCollection postCollection)
{
string presentValue = _text;
string postedValue = postCollection[postDataKey];

if (!presentValue.Equals(postedValue))
{
_text = postedValue;
return true;
}
return false;
}

Nov 19 '05 #2
Thanks for the recommendation....perhaps a custom attribute for the
whole form, maybe a comma delimited string of previous values...

However I do have a multiline textbox, so there could be alot of data
to append.

This seems so obvious that there should be ControlCollection.isDirty or
..Changed...

I don't know how to get to it as RaiseChangedEvents is private....

Maybe I will go apeshit and disassembly the System.Web.UI dll and make
that method overrideable....

hmmm...ideas...ideas....performance-wise unknown..
Gopal (FMS, Inc.) wrote:
You could save the original value as a custom attribute and later retrieve it to compare with what was posted back.
Hope this helps.
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...
Hello, I have a asp.net page with a form with 15 textboxes and a
couple of dropdownlists....I want to know if their is a way
(...serverside please...) of checking if any change has been made to any of these controls before I send and update to the database....I
would rather not have a OnTextChanged & OnSelectedItemChanged with
postback set to false for every control on the page...

I have been trying to implement the IPostBackEventHandler in the page System.Web.UI.Page, IPostBackEventHandler

and then override methods in it, but I think this is mostly for
customcontrols

public override void RaisePostBackEvent( IPostBackEventHandler
sourceControl, string eventArgument)
{
Response.Write( "<b>This is the RaisePostBackEvent event.</b><br>" ); }

public virtual void RaisePostDataChangedEvent()
{
Response.Write( "<b>This is the RaisePostDataChangedEvent");
}

public virtual bool LoadPostData(string postDataKey,
NameValueCollection postCollection)
{
string presentValue = _text;
string postedValue = postCollection[postDataKey];

if (!presentValue.Equals(postedValue))
{
_text = postedValue;
return true;
}
return false;
}


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Rob Meade | last post: by
1 post views Thread by Adam Right | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.