document.getElementById("<%=this.控制項ID.ClientID %>").value
母版 Master
document.getElementById('<%= Page.Master.FindControl("ContentPlaceHolder1").FindControl("Button1").ClientID %>').click();
母版這樣也抓的到哦
var id = $get("<%=lbl_case_oid.ClientID%>").innerText;
alert(id);
<script type="text/javascript">
function lookClientID() {
// str = document.getElementById("<%=this.DropDownList2.ClientID%>").value;
//alert(str); //出來是值
str = document.getElementById("<%=this.DropDownList2.ClientID%>");
alert(str.id); //出來是控制項ID
}
</script>
=============更新============================================
<script type="text/javascript">
function lookClientID() {
str = document.getElementById("<%=this.DropDownList2.ClientID%>").value;
if (str == "") {
alert("請選資料")
} else {
strtxt = document.getElementById("<%=this.TextBox1.ClientID%>");
strtxt.value = str;
}
</script>
=============抓下拉選單的顯示文字,不是抓value====================
<script type="text/javascript">
function lookClientID() {
str = document.getElementById("<%=this.DropDownList2.ClientID%>").value;
if (str == "") {
alert("請選資料")
} else {
strddl = document.getElementById("<%=this.DropDownList2.ClientID%>");
var index = strddl.selectedIndex;
var strval = strddl.options[index].text;
alert(strval);
}
}
</script>
============================================
曾遇見 window.onload 抓不到控制項的問題
後我來 改到 <body onload="timedCount()"> 才抓到控制項
沒有留言:
張貼留言