开发者

retain html div elements after updatepanel update in asp.net

开发者 https://www.devze.com 2023-01-14 13:48 出处:网络
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

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消