0

这就是发生的事情。我不明白为什么它不起作用,因为如果我将代码复制到普通模板,一切正常:S 所以我不认为它是代码问题。我正在使用 asp 和 c#![在此处输入图像描述][1]

http://s21.postimg.org/3jsi8351z/weird.png这是我用来解释问题的打印屏幕

ASP:

<asp:panel ID="pnltopico" runat="server" GroupingText="Topico" Height="100px" 
Width="550px" Visible="False" Wrap="False"> 
<asp:DropDownList ID="droptopico" runat="server" AutoPostBack="True" 
DataSourceID="SqlDataSource1" DataTextField="nome" DataValueField="Id_topico" 
Height="22px" 
onselectedindexchanged="DroptopicoSelectedIndexCha nged" Width="169px">
</asp:DropDownList> 
<asp:panel ID="pnlpermissoestopico" runat="server" GroupingText="Permissões" 
Height="59px" style="margin-top: 0px" Width="354px" Wrap="False" 
ClientIDMode="inherit"> 
<asp:ListBox ID="lbpermitidotp" runat="server" 
EnableViewState="true" Height="80px" 
></asp:ListBox>
<asp:Button ID="btnproibirtp" runat="server" onclick="BtnpermitirClick" 
Text="&gt;&gt;" /> 
<asp:Button ID="btnpermitirtp" runat="server" onclick="BtnnaopermitirClick" 
Text="&lt;&lt;" Height="26px" /> 
<asp:ListBox ID="lbproibidotp" runat="server" 
EnableTheming="False" EnableViewState="true" Height="80px" onselectedindexchanged="lbproibidotp_SelectedIndex Changed" 
></asp:ListBox> </asp:panel>

由于代码工作正常,我认为我不需要发布 c# 代码,但如果它可以帮助,请告诉我。感谢您的帮助

4

1 回答 1

0

嘿我刚刚修改了你的代码并编译它现在一切正常:

<asp:panel ID="pnltopico" runat="server" GroupingText="Topico" Height="100px" 
Width="550px" Visible="False" Wrap="False"> 
<asp:DropDownList ID="droptopico" runat="server" AutoPostBack="True" 
 DataTextField="nome" DataValueField="Id_topico" 
Height="22px" 
onselectedindexchanged="droptopico_SelectedIndexChanged" Width="169px">
</asp:DropDownList> 
    </asp:panel>
<asp:panel ID="pnlpermissoestopico" runat="server" GroupingText="Permissões" 
Height="59px" style="margin-top: 0px" Width="354px" Wrap="False" 
ClientIDMode="inherit"> 
<asp:ListBox ID="lbpermitidotp" runat="server" 
EnableViewState="true" Height="80px" 
>
    <asp:ListItem Text="Admin" Value="Admin" />
    <asp:ListItem Text="Guest" Value="Guest" />

</asp:ListBox>
<asp:Button ID="btnproibirtp" runat="server" OnClick="btnproibirtp_Click"
Text="&gt;&gt;" /> 
<asp:Button ID="btnpermitirtp" runat="server"  
Text="&lt;&lt;" Height="26px" /> 
<asp:ListBox ID="lbproibidotp" runat="server" EnableTheming="False" EnableViewState="true" Height="80px">
      <asp:ListItem Text="Moderator" Value="Moderator" />
    <asp:ListItem Text="Utilizer" Value="Utilizer" />
</asp:ListBox> </asp:panel>

我已经在 btnproibirtp 的按钮单击上设置了断点,只是为了验证它是否正常工作,我认为你有一些标签形成错误左右:

 protected void btnproibirtp_Click(object sender, EventArgs e)
    {
        string lbl1 = lbproibidotp.SelectedValue;
    }

问候

于 2013-05-09T14:32:33.950 回答