以textboxt显示数据 [英] display data in textboxt

查看:220
本文介绍了以textboxt显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



如果单击下拉列表,如何在textboxt中显示数据。

此代码仅在设计器中,当我点击下拉列表,我将显示数据,您也可以编辑和更新数据。





Hi All,

How to display data in textboxt when you click dropdownlist.
This code only in designer, when i click dropdownlist,i will appear data and you may also can edit and update it data.


<table style="width: 100%">
        <tr>
            <td align = "right" style="height: 67px">
                <asp:Label ID="LabelResp" runat="server" Text="Response Status: "

                 ></asp:Label>
            </td>
            <td style="height: 67px">
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td colspan="2" >
                <asp:TextBox ID="TextBox1" runat="server" Height="300px" Width="500px" ></asp:TextBox>
                <asp:HtmlEditorExtender ID="TextBox1_HtmlEditorExtender" runat="server"  DisplaySourceTab ="false" EnableSanitization ="false"

                    Enabled="True" TargetControlID="TextBox1">
                </asp:HtmlEditorExtender>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <br />
                <asp:Button ID="Button1" runat="server" Text="Save" />
                <asp:Label ID="lblMessage" runat="server" ForeColor="#009933"></asp:Label>
            </td>
        </tr>
    </table>







提前致谢。




Thanks in advance.

推荐答案

1.set DropDownList的属性: AutoPostBack = true



2.add onchange event

1.set DropDownList's attribute : AutoPostBack=true

2.add onchange event
<asp:dropdownlist id="DropDownList1" onchange="change()" runat="server" autopostback="True" >



3.


3.

function change(){
document.getElementById("TextBox1").innerText="1234";
}



以前的代码是客户端scrpit。



服务器代码:add SelectedIndexChanged 事件


the previous code is client scrpit.

Server code :add SelectedIndexChanged event

<asp:dropdownlist id="DropDownList1" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server" autopostback="True" >




protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text="1234";
}



http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.listcontrol.selectedindexchanged.aspx [ ^ ]


这篇关于以textboxt显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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