Tuesday, July 06, 2004

Hooking up Client Side Jave Script with MyButton.Attributes.Add()

The Session[MadeChangesIndex] stores a boolean indicating if any changes have been made to the lists/data grids.


In the Page_Load() Handler added:


if((bool)Session[MadeChangesIndex])
Cancel_PB.Attributes.Add("onClick", "return(HandleCancel(true));");
else
Cancel_PB.Attributes.Add("onClick", "return(HandleCancel(false));");


In the HEAD tag of the HTML added:

function HandleCancel(ListChanged)
{

if(ListChanged)
return(confirm("Are you sure you want to Discard ALL of your Edits? This includes any changes to the Work Item, Participant and Client Lists."));
else
return(confirm("Are you sure you want to Discard ALL of your Edits?"));

}

Works Great!

What I'd like to do is figure out how to walk the elements of the form and determine if any of the controls have been modified and exit without confirmation if nothing has changed.

No comments:

C# Sucks!

JK!! Seriously, though, somewhere around C#-3 we should have inculcated ourselves with the question: "Does 'CAN' == 'SHOULD...