js就可以了。ajax不是万金油,没有必要还是少用。写个js方法 function selectchange() { var select1 = document.getElementById("<%= DropDownList1.ClientID %>"); var textbox1 = document.getElementById("<%= TextBox1.ClientID %>") textbox1.value = select1.options[select1.selectedIndex].value; }在后台pageLoad时绑定事件this.DrowDownList1.Attributes.Add("onchange","selectchange()");
前台代码脚本: <script> function MyChange() { var DropName=document.getElementById("DropDownListName").value; document.getElementById("TextBoxName").value=DropName; }
<asp:DropDownList id="DropDownList1" runat=server onclick="document.getElementById('你的TextBox的id').value=this.value">
function selectchange()
{
var select1 = document.getElementById("<%= DropDownList1.ClientID %>");
var textbox1 = document.getElementById("<%= TextBox1.ClientID %>")
textbox1.value = select1.options[select1.selectedIndex].value;
}在后台pageLoad时绑定事件this.DrowDownList1.Attributes.Add("onchange","selectchange()");
<script>
function MyChange()
{
var DropName=document.getElementById("DropDownListName").value;
document.getElementById("TextBoxName").value=DropName;
}
</script>
后台代码:
this.DropDownListName.Attributes.Add("onchange", "MyChange()");
就纯js控制而已,这样就可以了DrowDownList1.Attributes.Add("onchange","document.getElementById('"+TextBox1.ClientID+"').value=this.value;");