DropDownList1.Attributes["onchange"]=string.Format(@"document.all['{0}'].value=this.Items[0].Text;",TextBox1.ClientID);我写的不起作用,请问该怎么写?
还想请教一个问题,就是document.all['{0}']后如何能知道有什么属性(相当于智能感知)?
还想请教一个问题,就是document.all['{0}']后如何能知道有什么属性(相当于智能感知)?
DropDownList1.Attributes["onchange"]=string.Format(@"document.all['{0}'].value=document.all['{1}'].value;",TextBox1.ClientID,随机生成的ID号);
参考
<!-- HTML 代码-->
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="aa">aa</asp:ListItem>
<asp:ListItem Value="bb">bb</asp:ListItem>
<asp:ListItem Value="cc">cc</asp:ListItem>
</asp:DropDownList>/*c# 代码*/protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
private void Page_Load(object sender, System.EventArgs e)
{
DropDownList1.Attributes["onchange"]=string.Format(@"document.all['{0}'].value=this.value;",TextBox1.ClientID);
}