javascript控制服务器控件——实例:为DropdownList动态添加删除选项

ASP.NET Web Forms Page模型深度解析:生命周期、ViewState与PostBack机制 ASP.NET Web Forms 的 Page 模型是微软早期为弥合前后端能力鸿沟而设计的服务端状态管理范式。其核心在于通过 HTTP 无状态协议模拟桌面应用体验,依托 Page 生命周期(PreInit→Render→Unload)、ViewState 自动状态持久化、PostBack 事件驱动机制,实现业务逻辑与 UI 渲染的深度耦合。该模型虽不适用于现代单页应用,但在政务、金融等强合规性遗留系统中仍具不可替代的工程价值——它降低了非前端开发者构建交互式表单的门槛,并保障了复杂表单级联、动态权限、服务 阅读详情

      最近多个页面需要加载一些下拉列表框,供用户选择,原来都是在服务器端进行加载应运用。最后由于

业务逻辑方面的考虑,需要将DropDownList的部分功能放到客户端实现。现在下拉列表的功能使用起来感

觉比全部放到服务器端性能好多了。

       具体方法:

       在页面中放入一个DropDownList控件,并添加一项,用来分析其产生的HTML代码,这样在使用js进行

动态控制时,将会非常清晰其测试代码如下所示:

<asp:DropDownList ID="DropDownList1" runat="server">

      <asp:ListItem>1</asp:ListItem>

</asp:DropDownList>

        在浏览器中查看,并对Html进行分析:以下是DropDownList控件生成的HTML代码。和普通的select没

有区别。那么也就可以通过js来动态填充、删除、选择等控制。


<select name="DropDownList1" id="DropDownList1">

       <option value="1">1</option>

</select>

    可以将<asp:ListItem>1</asp:ListItem>删除,现在添加两个HTML button控件,分别用来实现添加选项,和删除所有选项。Button源码如下:

<input id="Button1" type="button" value="添加Option" onclick="addOption()" />

<input id="Button2" type="button" value="全部删除Option" onclick="delOption()" />

    添加和删除函数如下所示:

function addOption(){

            var ddlObj = document.getElementById("DropDownList1");//获取对象

            if(ddlObj.length>0)

                delOption();//先删除所有的,之后在添加           

            var optText = new Array("founder","china","beijing");

            var optValue = new Array("0","1","2");

           

            var oOption = null;

            for(var i=0;i<optText.length;i++){

                 oOption = new Option(optText[i],optValue[i]);

                ddlObj.options.add(oOption);

            }

        }

        function delOption(){

            var ddlObj = document.getElementById("DropDownList1");//获取对象

            for(var i=ddlObj.length-1;i>=0;i--){

                ddlObj.remove(i);//firefox不支持ddlCurSelectKey.options.remove(),IE两种均支持

            }

        }

    在浏览器中查看,可以轻松地创建选择下拉选项,由于这些是客户端生成,因此其效率上要高于服务器

端工作的代码。但是这个时候如果要使用DropDownList1.SelectedValue获取用户选择的选项,那么你会得

到一个错误。这是由于DropDownList是由JS动态添加的,因此,它的项不属于ViewState,并且不被维护,

也就是说我们无法在服务器端对其进行处理。为了解决这一问题,可以使用两种方式:1、Hidden控件保存

用户选项方式;2、Request.Form方式。(参见msdn品味Ajax)

    1、我们在页面中添加一个Hidden控件,用它来保存DropDownList选项变化的信息,这样在用户选择感

兴趣的信息之后,我们就可以在服务器端获取信息,并进行处理,合理地实现客、服之间的分工。

     对DropDownList控件添加一个onchange事件,此时它的html代码如下所示:

<asp:DropDownList ID="DropDownList1" runat="server" onchange="ResvItem()">

</asp:DropDownList>

     Onchange事件如下所示,该事件主要保存用户选定的value:

function ResvItem(){

        var objDdl = document.getElementById("DropDownList1");

        document.getElementById("HiddenField1").value = objDdl.options[objDdl.selectedIndex].value;

    }

     在此之后,我们使用一个asp:button控件来测验结果:

protected void Button1_Click(object sender, EventArgs e)

    {

        Response.Write(HiddenField1.Value);

    }

    

    到此,已经完成了所有的工作,但是还有一个问题,DropDownList的change事件只有在用户改变下拉选

项时才会触发。因此,用户使用默认选项进行提交时,则获取空值。因此我们可以在填充option时,即对

hidden初始化。对addOption事件添加一行代码如下:

function addOption(){

        var ddlObj = document.getElementById("DropDownList1");//获取对象

        if(ddlObj.length>0)

            delOption();//先删除所有的,之后在添加           

        var optText = new Array("founder","china","beijing");

        var optValue = new Array("0","1","2");

           

        var oOption = null;

        for(var i=0;i<optText.length;i++){

            oOption = new Option(optText[i],optValue[i]);

            ddlObj.options.add(oOption);

        }

        document.getElementById("HiddenField1").value = optValue[0];

    }

 

 

 

 

不过以上红色部分在TT浏览器下ADD不成功,其他浏览还没试过,以下是另一个种写法:

 

 function GetDeptList()
    {
          var ddlCityType = document.getElementById("ddlCityType");
          var ddlPosition = document.getElementById("ddlPosition");
           var v = ddlCityType.options[ddlCityType.selectedIndex];
           //alert(v.value);
         
          var DeptList=Guest_UserRegister.GetDeptList(v.value).value;
         
         var deptList=new Array();
          deptList=DeptList.split(';');
          for(var i=0;i<deptList.length;i++)
          {
             if(deptList[i]!="")
             {
                  var dept=deptList[i].split(',');
                  var opt = document.createElement("option");
                  opt.innerHTML = dept[1];
                  opt.value = dept[0];
                  ddlPosition.insertBefore(opt, ddlPosition.firstChild);
              }
          }
    }
    function DelOption()
    {
        var ddluserSchool = document.getElementById("ddluserSchool");
        var num=ddluserSchool.length;
        while(num>0)
        {
            for(var j=0;j<num;j++)
           {
            ddluserSchool.remove(j);
           }
           num=ddluserSchool.length;
        }
      
    }
    function GetSchoolList()
    {
          DelOption();
          var ddlProvince = document.getElementById("ddlProvince");
          var ddluserSchool = document.getElementById("ddluserSchool");
          var v = ddlProvince.options[ddlProvince.selectedIndex];
         var DeptList=Guest_UserRegister.GetSchoolList(v.value).value;
         var deptList=new Array();
          deptList=DeptList.split(';');
          for(var i=0;i<deptList.length;i++)
          {
             if(deptList[i]!="")
             {
                  var dept=deptList[i].split(',');
                  var opt = document.createElement("option");
                  opt.innerHTML = dept[1];
                  opt.value = dept[0];
                  ddluserSchool.insertBefore(opt, ddluserSchool.firstChild);
                 
              }
          }
    }

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yytt123622/archive/2009/04/14/4071425.aspx

FineUI三生石:Web Forms状态管理的工程化实践 Web UI状态管理是前端与服务端协同的核心命题,其本质在于数据加载、交互流转与回传还原三个关键阶段的可控性保障。FineUI提出的‘三生’模型——First Life(初生加载)、Second Life(交互流转)、Third Life(PostBack还原)——并非概念包装,而是对ASP.NET Web Forms生命周期中三大原罪(ViewState失控、PostBack语义模糊、状态不同步)的精准工程解法。该设计强调服务端权威、状态可预测与交付可审计,特别适用于政企级遗留系统维护、安全合规场景下的可 阅读详情

相关推荐

[Ext.Net]1.X _德仔铁观音学习笔记整理

1 .配置及简单布局 2.常用组件介绍      2.1 Dropdownlist结合TreePanel (checkbox)      2.2 模拟进度条      2.3 上传文件      2.4 TabPanel基本用法          2.4.1 TabPanel基本用法         2.4.2 控制最多可以打开N个页面      2.5 执行后台程序提示等待信息,

德仔 5671

asp.net 中的DropDownList控件的前台与后台

asp.net中封装了下拉框,名称为DropDownList。该控件可以在网页加载时在后台代码中进行初始化,即在.cs文件中初始化。如果在页面中在页面不刷新的情况下,js代码改变了该下拉框的数据,虽然在当前页面下拉框数据已经改变,但是页面重新刷新js代码改变的数据并未保留,显示的还是之前初始化时的数据。保持js改变的数据方法如下:          1.使用ajax将js修改后的下拉框中的数据全

孙悟空空的专栏 2225

拆开华为BBU5900,看看5G基站的大脑里到底装了啥?

本文深度拆解华为BBU5900,揭示5G基站核心处理单元的硬件架构与设计哲学。通过详细解析模块化设计、智能电源系统和动态散热方案,展现其支撑千兆速率、毫秒级时延的技术奥秘,为5G网络部署提供实用参考。

weixin_31456563的博客 586

JavaScript为DropDownList添加新项

JS获取DropDownList的value值与text值 <scripttype="text/javascript"language="javascript"> functionSearchChange() { varddl=document.getElementById("DropDownList1") ...

weixin_33957648的博客 591

AD5940阻抗测量开发板实战:从源码获取到工程调试全解析

本文详细解析了AD5940阻抗测量开发板的实战应用,从源码获取到工程调试的全过程。AD5940作为ADI公司的高精度阻抗测量前端芯片,适用于生物阻抗分析、电化学传感器等领域。文章提供了开发环境搭建、工程配置、常见问题排查及进阶调试技巧,帮助开发者快速掌握AD5940开发板的使用方法。

weixin_30919429的博客 215

STM32实战:用定时器触发ADC+DMA双缓冲实现电机电流采样(附避坑指南)

本文详细介绍了如何利用STM32的定时器触发ADC注入组采样,结合DMA双缓冲机制实现电机电流的高效采样。通过PWM触发和双缓冲架构,解决了开关噪声干扰、实时性要求和数据一致性等核心挑战,显著降低CPU负载并提升采样精度。附有完整的代码示例和避坑指南,适用于无人机电调、工业伺服驱动器等高精度电机控制场景。

weixin_33737134的博客 525

JS清除dropdownlist绑定的项,并添加新项

<script type="text/javascript"> /*删除项*/ document.getElementById('KeyList').options.length = 0; /*添加项*/ document.getElementById("KeyList").options.add(new Option( "English Title", "e...

weixin_30773135的博客 281

低成本实现webhook接收端[python]

Webook本质上也是API,只不过是反向调用,即前端不主动发送请求,完全由后端推送。简单来说,Webhook是一个接受HTTP POST或是GET,PUT,DELETE的URL,一个实现了Webhook的API提供商就是在当事件发生的时候会向配置的URL发送信息,与请求-响应式不同,使用Webhook可以实时接收到变化。Ps:Webhook可能会发出大量的请求,确保接受的URL不被泄露或者应用能及时处理这些请求。

锡城小凯的博客 1万+

给服务器端DropDownList控件添加客户端onchange事件

我们在许多是时候,要在DropDownList添加一个onchange事件,在.Cs文件中我们还有一个onSelectedIndexChanged事件,我们添加它的onchange事件,大部分就是为了在客户端先让用户确认一下,在回传服务器,提高用户体验性。 而如果我们在Html源代码中,自己给它加上onchange事件的话,有可能提示"服务器标记不正确"...

weixin_30814329的博客 351

PCIE协议版--M.2接口规范V1.0中文版1——物理规格篇

5.1.3.双模块键模块:同时支持Socket1-DP、Socket1-SD。2.4.7.3.3.双面模块(使用H2.8、H3.2、H4.2连接器)6.5.8.2.5.热设计功率响应-带有风扇类别的薄平台笔记本电脑。2.3.7.1. Socket1&2射频连接器PIN-OUT。5.2.2.Socket2 PIN-OUT(机械KEY B)3.2.10.1.3.极薄的笔记本电脑的电源开关顺序的例子。5.1.1.Socket1-DP(机械KEY A)5.1.2.Socket1-SD(机械KEY E)

想你所想,做你所做 4689

HTML蓝色动态爱心(完整代码)

HTML语言实现蓝色动态爱心的完整代码。

AIGC 8万+

javascript控制服务器控件实例一

最近多个页面需要加载一些下拉列表框,供用户选择,原来都是在服务器端进行加载应运用。最后由于 业务逻辑方面的考虑,需要将DropDownList的部分功能放到客户端实现。现在下拉列表的功能使用起来感 觉比全部放到服务器端性能好多了。 具体方法: 在页面中放入一个DropDownList控件,并添加一项,用来分析其产生的HTML代码,这样在使用js进...

weixin_30916125的博客 81

海思SD3403/SS928V100开发(6)单路GMSL-MIPI-YUV相机视频输入调试

硬件连接:森云GMSL相机 -> GMSL 解串器 -> SD3403 MIPI0暂时先进行单路视频输入通路调试。

jzwjzw19900922的博客 1939

WEB开发文档2 总结

转自:http://blog.donews.com/lvjiyong/archive/2006/06/29/931071.aspx怎样将后台生成的在内存中的图象显示到客户端Microsoft IE WebControls下载地址如何在DATAGRID中使用JAVASCRIPT脚本控制DataGrid中连接到下一页显示数据下载中文名文件时保存文件名乱码问题关于用ASP.net绘图的问题,请大虾指教那

小北 4580

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ASP.NET状态管理原理与实战决策指南

Web应用的状态管理,本质是应对HTTP无状态协议带来的数据连续性挑战。其核心原理在于权衡客户端与服务端的计算、存储和网络资源:客户端方案(如QueryString、Hidden Field、Cookie)降低服务器压力但增加传输负担与安全风险;服务端方案(如Session、ViewState、ApplicationState)保障一致性却影响扩展性与性能。在云原生与高并发场景下,合理选择状态载体——区分数据生命周期、敏感性、体积及集群需求——直接决定系统可维护性与伸缩能力。本文结合ASP.NET典型机制,

diaoqi6581的博客 365

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

asp.net c# DropDownList删除一条数据,删除项

[code="c#"]DropDownList1.Items.Remove(DropDownList1.Items.FindByText("天空"));//按显示文本删除 DropDownList1.Items.Remove(DropDownList1.Items.FindByValue("sky"));//按值删除 [/code] 不能DropDownList1.Items.Rem...

黑色头发 1122

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

给dropdownlist等控件增加客户端onchange事件

dropdownlist等控件的onchange事件,如果同时要触发js弹出框,则采用以下方法: 后台:    if (iStatusNo == (int)ZTE.EVAL.Model.EnumCollections.InvestigateStatus.已发布)    {         this.ddlOperation.Items.Add(new ListItem(OperType.预

johncools的博客 2797

js控制dropdownlist

//这里是HTML代码 <asp:DropDownList ID="ddlWorkType" runat="server" Width="150px"> </asp:DropDownList> //这里在后台绑定值 [csharp] view plaincopyprint? DataSetworkTypeDts=_publicCodeManager.Ge...

weixin_30776545的博客 180

JS 获取asp:DropDownList下拉框控件的值

维护公司一个运行三四年的老项目,发现有一个页面是使用asp:DropDownList控件来实现下拉框的,这种使用asp控件的实现思路都是在cs文件中绑定和获取下拉框的数据,但是我们需要在js中获取asp:DropDownList选择的数据。本来最好的办法是用JS重写整个页面,但是重写整个页面工作量太大了,所有从网上找到了一个折中的办法,在js中获取获取asp:DropDownList选择的数据。 1、aspx页面 <asp:DropDownList ID="dropDownLis...

旭东怪的博客 1484

js、jquery获取asp:dropdownlist值的方法

一、js 获取asp:dropdownlist选中的值 var eSection = document.getElementById("<%=tx_ddlType.ClientID%>"); var eSectionValue = eSection.options[eSection.selectedIndex].value; alert(eSectionValue); 二、jQuery获取asp:dropdownlist选中的值 //获取value值 $("#ddlSubmodel").val(

hmwz0001的博客 2400

asp:DropDownList动态绑定数据,设置默认值

DropDownList值绑定

半块菠萝的博客 7791

Dropdownlist的onchange事件应用

1 function selectDpList(dp) { 2 var sIndex = dp.selectedIndex;//返回选中是第几项 0,1.... 3 var sText = dp.options[dp.selectedIndex].text;//返回选中的文本--文本1,文本2 ... 4 var...

weixin_33737134的博客 923
上一篇: C#(.Net) 配合WQL实现并口读写
下一篇: JS 数组
jaychlas
博客等级 码龄17年 13粉丝 34原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值