我如何在ASP.NET的Listbox控件中添加-通过javascript获取的任何值? [英] how can i add - any value obtained by javascript - to Listbox control in asp.net ?

查看:74
本文介绍了我如何在ASP.NET的Listbox控件中添加-通过javascript获取的任何值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

步骤:

用户将要按下位于ASP.NET页面中的按钮控件.然后Button执行下面的javasccript代码.在用户输入名称之后,该名称将显示在Listbox控件中吗?


Hi guys ,

Steps :

User is going to push the button control which is located in ASP.NET page.Then Button executes the javasccript code below.After user has written his/her name , the name is going to be shown in Listbox control ?


function prompter() {
      var reply = prompt("Hey there, good looking stranger!  What's your name?", "")

  }

推荐答案

我用Google搜索并发现 ^ ]为您服务.如果您使用诸如
之类的jquery,则使用jquery会更容易.
I googled and found this[^] for you. Using jquery would be easier, if you use jquery such as


(" span>).append(" anOption >一个Option</option>");
("#mylistbox").append("<option value="anOption">An Option</option>");



现在,不要忘记,在ASP.NET中,您需要从控件的ClientID属性中获取客户端ID.我会将其发送到javascript变量中,以便您可以将大部分脚本放入js文件中.



Now, don''t forget, in ASP.NET, you need to get the client side id from the ClientID property of the control. I''d emit that in to a javascript variable so you can put most of your script in a js file.


这篇关于我如何在ASP.NET的Listbox控件中添加-通过javascript获取的任何值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆