Cómo configurar document.getElementById (progressPanel.ID) en la página aspx.cs

I have javascript which sets the location of panel and javascript is below

function ShowProgressPanel(progresspanel)
{
    var progressPanelId = document.getElementById(progressPanel.ID);
    alert(progressPanelId);
    if (progressPanelId != null) 
    {

        var height = Math.min(document.documentElement.clientHeight, document.body.offsetHeight);
        alert(height);
        var width = Math.min(document.documentElement.clientWidth, document.body.offsetWidth);
        var xPos = Math.round((width / 2) - (progressPanelId.clientWidth / 2));
        var yPos = Math.round((height / 2) - (progressPanelId.clientHeight / 2));
        setLocation(progressPanelId, { x: xPos, y: yPos });
    }

    function setLocation(element, point) 
    {
        Sys.UI.DomElement.setLocation(element, point.x, point.y);
    }
}

I am passing client id from aspx page

var progressPanel = document.getElementById('<%=_progressPanel.ClientID %>');

ShowProgressPanel(progressPanel);

it is set to html div tag.above code works fine.when i send through aspx.cs page it shows contentplace holder element and height is not set.

string script = string.Format(@"ShowProgressPanel('{0}');", _progressPanel.ClientID);
ScriptManager.RegisterStartupScript(this, typeof(Page), _progressPanel.ID, script, true);

But in both progress panel is placed in contetnplaceholder. How shall i do it in aspx.cs page

preguntado el 08 de noviembre de 11 a las 09:11

1 Respuestas

You are mixing the element and the id up.

function ShowProgressPanel(progresspanelId)
{
    var progressPanelElement = document.getElementById(progresspanelId);

    setLocation(progressPanelElement , { x: xPos, y: yPos });
}

function setLocation(element, point) 
{
    Sys.UI.DomElement.setLocation(element, point.x, point.y);
}

respondido 08 nov., 11:14

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.