views:

19

answers:

1

I use jquery facebox as delete confirmation box. When i do a delete it removes my record and i show the resultsdiv via javascript. But it always shows

Error: document.getElementById("ImageButtonDiv") is null

here is my code,

protected void Delete_Click(object sender, EventArgs e)
{
    // my delete
    ScriptManager.RegisterClientScriptBlock(Delete, typeof(Button), "dele", 
          "ShowImageButtonDiv();topBar('Successfully Deleted');", true);
}

and my javascript function,

function ShowImageButtonDiv() {
    document.getElementById("ImageButtonDiv").style.display = 'block';
    document.getElementById("datatable").style.display = 'block';
    document.getElementById("adddiv").style.display = 'none';
    return true;
}

EDIT:

When my delete confirmation is not within a jquery facebox it gets my element. What could be the issue?

I ve replaced but still not working,

ScriptManager.RegisterClientScriptBlock(LbDelete, typeof(LinkButton), "dele", 
 "jQuery(document).ready(function(){UsersDatatable('" + HfJsonString.Value + "');
        ShowImageButtonDiv();topBar('Successfully Deleted');});", true);
+1  A: 

This is happened because your script is probably run before the dom is ready so he can not find the ImageButtonDiv.

You can change that by place this code to run when dom is ready For example.

 ScriptManager.RegisterClientScriptBlock(Delete, typeof(Button), "dele", 
          "jQuery(document).ready(function(){ ShowImageButtonDiv();topBar('Successfully Deleted'); });"
, true);
Aristos
@Aristos still not working?
Pandiya Chendur
@Aristos look at my edit..
Pandiya Chendur
@Aristos just change `jQuery` to `$` it worked..
Pandiya Chendur
@Pandiya Sorry, I use the jQuery for compatibility reasons. The $ is the same as jQuery when not make the switch to compatibility
Aristos
@Aristos thanks for the help...
Pandiya Chendur