转自:http://bytes.com/topic/asp-net/answers/443065-textbox-value-change-select-other-item-dropdownlist

You need to add the below javascript in ur html section of the page

<script language="javascript">
function ShowValue()
{
document.Form1["textboxname"].value =
document.Form1["dropdownvalue"].value
}
</script>
and in the codebehind file add this line

Dropdowncontrol.Attributes.Add("onchange","javascr ipt:ShowValue()");

Now when you change the value in the drop down, the Textbox will be
filled without refreshing the page

http://forums.asp.net/t/1796597.aspx?How+to+select+a+value+in+dropdownlist

<head runat="server">
<script type="text/javascript">
function sethref() { var Textb = document.getElementById('<%=TextBox1.ClientID%>');
var parLab = document.getElementById('<%=Dropdown1.ClientID%>').options[document.getElementById('<%=Dropdown1.ClientID%>').selectedIndex].text; if(parLab!='--select deptname--'){
Textb.value = parLab
} else{ Textb.value =''; } }
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="reload" runat="server" onclick="reload_Click"/>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:DropDownList ID="Dropdown1" runat="server" onchange="sethref();">
<asp:ListItem>--select deptname--</asp:ListItem>
<asp:ListItem>mama</asp:ListItem>
<asp:ListItem>kaka</asp:ListItem>
<asp:ListItem>nana</asp:ListItem> </asp:DropDownList>
</div>
</form>
</body>
</html>

http://blog.csdn.net/lvincent_china/article/details/7209517

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=DropDownList1.ClientID %>').bind("keyup change", function () {//use bind() to attach a handler to the keyup and change events:
$('#message').text("");
if ($(this).val() != "") {//Check if the selected value of the DropDownList is empty
$('#message').text("Text:" + $(this).find(":selected").text() + "value:" + $(this).val()); //Retrieve the Text/Value pair and display in the div area 'message':
}
else {
$('#message').text("");
}
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="" Text="please select"></asp:ListItem>
<asp:ListItem Value="" Text="Standard"></asp:ListItem>
<asp:ListItem Value="" Text="Silver"></asp:ListItem>
<asp:ListItem Value="" Text="Gold"></asp:ListItem>
<asp:ListItem Value="" Text="Premier"></asp:ListItem>
</asp:DropDownList>
</div>
<div id="message"></div>
</form>
</body>
</html>

TextBox的值随dropdownlist值而变化的更多相关文章

  1. MVC控制器获取@Html.DropDownList值

    MVC控制器获取@Html.DropDownList值 发表于 2014 年 4 月 1 日 作者 efour — 暂无评论 先贴一段代码,演示@Html.DropDownList的使用. 前台 前台 ...

  2. jQuery封装自定义事件--valuechange(动态的监听input,textarea)之前值,之后值的变化

    jQuery封装自定义事件--valuechange(动态的监听input,textarea)之前值,之后值的变化 js监听输入框值的即时变化 网上有很多关于 onpropertychange.oni ...

  3. Facebook开源时间序列内存数据库Beringei,追求极致压缩率——如果是int根据大多数时间序列中的值与相邻数据点相比并没有显著的变化,只要使用XOR将当前值与先前值进行比较,然后存储发生变化的比特。最终,该算法将整个数据集至少压缩了90%

    转自:http://www.infoq.com/cn/news/2017/02/Facebook-Beringei 2017年2月3日,Facebook宣布将开源他们的高性能时序数据存储引擎Berin ...

  4. EF里查看/修改实体的当前值、原始值和数据库值以及重写SaveChanges方法记录实体状态

    本文目录 查看实体当前.原始和数据库值:DbEntityEntry 查看实体的某个属性值:GetValue<TValue>方法 拷贝DbPropertyValues到实体:ToObject ...

  5. Oracle新表使用序列(sequence)作为插入值,初始值不是第一个,oraclesequence

    Oracle新表使用序列(sequence)作为插入值,初始值不是第一个,oraclesequence 使用oracle11g插入数据时遇到这样一个问题: 1 --创建测试表-- 2 CREATE T ...

  6. javascript中值传递与值引用的研究

    今天重新看了一下<javascript高级程序设计>,其中讲到了javascript中的值传递和值引用,所以就自己研读了一下,但是刚开始没有明白函数中的参数只有值传递,有的场景好像参数是以 ...

  7. easyUI validatebox设置值和获取值,以及属性和方法

    一:表单元素使用easyui时,textbox和validatebox设置值和获取值的方式不一样[转] 1.为text-box设置值只能使用id选择器选择表单元素,只能使用textbox(" ...

  8. JavaScript数据操作--原始值和引用值的操作本质

    我的一句话总结:原始值不管是变量赋值还是函数传递都不会改变原值,引用值不管是变量赋值还是函数传递,如果新变量重新赋值,则不会影响原引用值,如新变量是直接操作,就会影响原引用值. 首先明确,值和类型是两 ...

  9. easyui-textbox 和 easyui-validatebox 设置值和获取值

    表单作如下定义:该input使用easyui的"easyui-textbox" <input id="addSnumber" style="wi ...

随机推荐

  1. 新建snmp模型总结

    1.在DeviceType.xml中添加新的模块 2.在modellidx.json中添加路径关联 3.添加定义模型 4.定义model.xml注意: 5.定义collect.xml注意:

  2. codeforces 599D Spongebob and Squares

    很容易得到n × m的方块数是 然后就是个求和的问题了,枚举两者中小的那个n ≤ m. 然后就是转化成a*m + c = x了.a,m≥0,x ≥ c.最坏是n^3 ≤ x,至于中间会不会爆,测下1e ...

  3. Python实现注册和登录

    一.注册账号需要实现的功能 1.输入:用户名,密码,密码确认 2.限制1:输入的账号和密码不能为空 3.限制2:两次输入密码必须一致 4.限制3:用户名不能重复 5.限制4:错误次数为4次 6.用字典 ...

  4. Struts2 In Action笔记_页面到动作的数据流入和流出

    因为回答百度知道的一个问题,仔细查看了<Struts2 In Action>,深入细致的看了 “数据转移OGNL 和 构建视图-标签”,很多东西才恍然大悟. 一直觉得国外写的书很浮,不具有 ...

  5. oc描述器排序

    int main(int argc, const char * argv[]) { @autoreleasepool { NSArray *array = @[CreateDict(@"王思 ...

  6. 定位设备--llseek实现

    /** 如果llseek实现lseek和llseek系统调用,如果未定义llseek方法, 内核默认修改file结构体中的f_pos成员来实现定位,如果是操作一个 设备,则需提供自己的llseek方法 ...

  7. Yii2.X 如何避开pathinfo不能处理中文名开头的bug

    /** * @return string original file base name */ public function getBaseName() { // https://github.co ...

  8. 常用模块之 re shutil configparser hashlib xldt和xlwd

    shutil 高级文件处理模块 封装的更简单了 主要是文件的复制,移动,压缩解压缩 需要保证目标文件已经存在shutil.copymode('test.txt','testcopy4.txt') 压缩 ...

  9. Codeforces Round #524 (Div. 2) C. Masha and two friends 思路

    题目:题目链接 思路:直接计数显然是不好处理的,但分情况讨论只要不写错这题是一定可以出的,但这样基本做完这个题就没时间做其他题了,但当时我就这么蠢的这样做了,比赛一个半小时的时候突然发现一个似乎可行的 ...

  10. German Collegiate Programming Contest 2018​ C. Coolest Ski Route

    John loves winter. Every skiing season he goes heli-skiing with his friends. To do so, they rent a h ...