如果我将该服务器控件的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);
}
答案 0 :(得分:0)
您需要更改LinkButton控件的innerText属性:
更改
document.getElementById(myID).value = 'abc';
到
document.getElementById(myID).textContent = 'abc';