I have spent the couple days researching my issue and have not been able to get it to work correctly. There are a few topics on StackOverflow that are related to this issue and reading them has helped me but I'm at a bit of a roadblock and would appreciate a push in the right direction.
I wrote a small .NET 3.5 VB.NET web application for a client that allows users to maintain some data. I'm using the RadGrid and RadComboBox controls and it consists of 3 pages. One requirement I was not completely fond of was that the user wanted to make all of her changes then hit a save button at the end instead of saving back to the DB each time she applied her changes to the grid.
I'm using an session object to store a collection of objects on each page and want to prompt the user with a dialog if they attempt to change the value of a dropdown or leave the page when there are pending actions. After a lot of research here and in other places, I decided to create a hidden field on the page and update its value each time the action collection is updated on the server side. Then I want to evaluate that value and if it's greater than 0, I want to prompt the user to save changes.
My function:
My hidden field declaration:
My server side code:
When I debug the application and add a record to my grid, the server side code is executed correctly. I have also verified that the hidden control is found by the javascript function. What I haven't been able to figure out, though, is why the hidden field value is not found by the function.
Any help is greatly appreciated. Thank you!
I wrote a small .NET 3.5 VB.NET web application for a client that allows users to maintain some data. I'm using the RadGrid and RadComboBox controls and it consists of 3 pages. One requirement I was not completely fond of was that the user wanted to make all of her changes then hit a save button at the end instead of saving back to the DB each time she applied her changes to the grid.
I'm using an session object to store a collection of objects on each page and want to prompt the user with a dialog if they attempt to change the value of a dropdown or leave the page when there are pending actions. After a lot of research here and in other places, I decided to create a hidden field on the page and update its value each time the action collection is updated on the server side. Then I want to evaluate that value and if it's greater than 0, I want to prompt the user to save changes.
My function:
<telerik:RadCodeBlock ID=
"RadCodeBlock2"
runat=
"server"
><br>
<script type=
"text/javascript"
><br>
window.onbeforeunload = confirmExit;<br>
function
confirmExit()<br>
{<br>
var
actionCount = $get(
'<%=ActionCounterField.ClientID %>'
).value;<br>
if
(actionCount > 0) {<br>
alert(
"Pending Changes!"
);<br>
}<br>
}<br>
<br>
</script><br>
</telerik:RadCodeBlock>
My hidden field declaration:
<
asp:HiddenField
id
=
"ActionCounterField"
runat
=
"server"
/>
My server side code:
<br>
Protected
Sub
UpdateActionCount()<br>
<br>
ActionCounterField.Value = GoalCategoryActionList.Count<br>
<br>
End
Sub
<br>
When I debug the application and add a record to my grid, the server side code is executed correctly. I have also verified that the hidden control is found by the javascript function. What I haven't been able to figure out, though, is why the hidden field value is not found by the function.
Any help is greatly appreciated. Thank you!