foremaro foremaro - 1 year ago 110
Javascript Question

Disabling aspxgridviews on server-side, how to handle on client-side?

I've just started a project where our BA guy needs me to disable all of our aspxgridviews past a certain time.

public void CutoffDateTime()
//DateTime today = DateTime.Now; // this will be for live code
DateTime today = new DateTime(2016, 4, 15, 7, 00, 00); // for testing
DateTime cutoff = new DateTime(2016, 4, 19, 7, 00, 00);

if (today >= cutoff.AddDays(7))
cutoff = cutoff.AddDays(7);
// if today is past cutoff, disable all grids
if (today < cutoff.AddHours(-55))
gvProduction.Enabled = false;
gvProductionSummary.Enabled = false;
gvDowntimeSummary.Enabled = false;
gvNonProd.Enabled = false;
cbCutoff.Checked = false;
cbCutoff.Checked = true;

The grids are disabled correctly, but this affects some client-side code that calls the grid.Refresh() methods.

I've added the checkbox as an invisible control so that I can easily interface with the client-side and I'm trying to add:

if (cbCutoff.GetChecked()==true)

But I am still getting JavaScript runtime errors stating that 'cbCutoff is undefined' but I can't think of another way to accomplish this task.



Here is part of my markup that I'm trying to fix via DexExpress' GetChecked() method that returns true if checked:


<ClientSideEvents ActiveTabChanged="function(s, e) {
if ( == 1 && cbCutoff.GetChecked()==true)
}" />

Answer Source

Fixed by using

    if (cb.GetChecked())

and set the checkbox to enabled on server-side

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download