I use jquery facebox as delete confirmation box. Wh开发者_如何学Pythonen 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);
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);
精彩评论