0

如果我将服务器控件的 ClientID 传递给 javascript,我可以设置服务器控件的值吗?

<script type="text/javascript">
    function FillTextFromPopup(text) {
        alert(text);
        var myID = '<%= Session["myID"].ToString() %>';
        alert(myID);

            document.getElementById(myID).value = 'abc';

    }
</script>


protected void LinkButton1_Click(object sender, EventArgs e)
    {
           GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            int index = gvRow.RowIndex;
            LinkButton lnk = (LinkButton)gvRow.FindControl("LinkButton1");
            string id = lnk.ClientID;
            Session["myID"] = id;
            string myScript;
            myScript = "<script>window.open('PopUpTest1.aspx?',null,'height=750, width=1024,status= no,resizable= no, scrollbars=yes,toolbar=no,location=no,menubar=no'); </script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", myScript, false);

    }
4

1 回答 1

0

您需要更改 LinkBut​​ton 控件的 innerText 属性:

改变

document.getElementById(myID).value = 'abc';

document.getElementById(myID).textContent = 'abc';
于 2013-10-01T07:24:18.843 回答