简体   繁体   English

从下拉列表值填充文本框-使用vb.net的asp.net

[英]populate textbox from dropdown list value - asp.net with vb.net

I am trying to get an "onchange" (not sure still new to asp) event to enter the select value text into a text box . 我正在尝试获取一个“ onchange”(不确定还是asp的新手)事件,以将选择值文本输入到文本框中。 I can seem to call the function. 我似乎可以调用该函数。

here is my code: 这是我的代码:

<asp:DropDownList ID="ownerdpdnlst" runat="server" ontextChanged="execvalchanged" >
                     <asp:ListItem Value="(Choose One)">Choose one...</asp:ListItem>
                     <asp:ListItem Value="name1">name1</asp:ListItem>
                     <asp:ListItem Value="name2">name2</asp:ListItem>
                     <asp:ListItem Value="name3">name3</asp:ListItem>
                     <asp:ListItem Value="name4">name4</asp:ListItem>
                     <asp:ListItem Value="name5">name5</asp:ListItem>
</asp:DropDownList>
</asp:TableCell>

here is my vb.net code 这是我的vb.net代码

<script runat=server>
    Public Sub execvalchanged(Sender As Object, e As EventArgs) Handles ownerdpdnlst.SelectedIndexChanged
        executortxtbx.Text = ownerdpdnlst.SelectedValue
        MsgBox(ownerdpdnlst.SelectedValue)
    End Sub
</SCRIPT>

any ideas? 有任何想法吗?

In aspx You define OnTextChanged but in code behind SelectedIndexChanged. 在aspx中,您定义OnTextChanged,但在SelectedIndexChanged之后的代码中。 In aspx, Instead ontextChanged="execvalchanged" use OnSelectedIndexChanged="execvalchanged"– nelekSep 12 at 6:32 在aspx中,改为使用onSelectedIndexChanged =“ execvalchanged” – nelekSep 12 at 6:32

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取文本框的先前值asp.net vb.net - Get previous value of textbox asp.net vb.net 如何将文本框的值从asp.net窗体带到vb.net代码后面的类 - How to take textbox value from an asp.net form to a classes in vb.net code behind 如何将值从文本框存储到asp.net vb.net应用程序中的javascript变量中 - How to store value from a textbox into a javascript variable in a asp.net vb.net application 编辑代码。如何使用vb.net从asp.net的下拉列表中显示gridview - Edited code.How to display gridview from dropdown list in asp.net using vb.net 使用文本框asp.net填充下拉列表 - populate dropdown using a textbox asp.net 如何在asp.net C#Web窗体应用程序中基于下拉列表的选定值填充文本框? - How to populate a textbox based on the selected value of a dropdown list in an asp.net c# web forms application? 使用 ASP.NET MVC 根据从下拉列表中选择的值填充文本框 - Populate a textbox based on selected value from dropdown using ASP.NET MVC 使用 ASP.NET MVC 根据从级联下拉列表中选择的值填充文本框 - Populate a textbox based on selected value from cascading dropdown using ASP.NET MVC 使用ASP.NET和AJAX从复选框列表填充文本框 - Populate textbox from checkbox list using ASP.NET and AJAX 在asp.net vb.net中为文本框保留事件 - leave event for textbox in asp.net vb.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM