gpt4 book ai didi

c# - 将 UpdatePanel 用于 asp.net TreeView SelectedNodeChanged 事件

转载 作者:太空宇宙 更新时间:2023-11-03 21:47:31 25 4
gpt4 key购买 nike

我有 TextBoxtreeview 喜欢,

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtName" runat="server" Width="150px" ReadOnly="true"
BorderStyle="Double">
</asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>

<asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" >
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
<SelectedNodeStyle CssClass="treeHover"></SelectedNodeStyle>
</asp:TreeView>

SelectedNodeChanged 事件编码,

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
txtName.Text = TreeView1.SelectedNode.Text;
}

我的更新面板不能正常工作,我想知道我的代码有什么问题?

最佳答案

试试这个....

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtName" runat="server" Width="150px" ReadOnly="true"
BorderStyle="Double">
</asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TreeView1" EventName="SelectedNodeChanged" />
</Triggers>
</asp:UpdatePanel>

<asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" >
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
<SelectedNodeStyle CssClass="treeHover"></SelectedNodeStyle>
</asp:TreeView>

关于c# - 将 UpdatePanel 用于 asp.net TreeView SelectedNodeChanged 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16191564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com