前台代码:
!<asp:DataList ID="DataListMyMessageBoard" runat="server" Width="100%"
onitemcommand="DataListMyMessageBoard_ItemCommand">
<HeaderTemplate>
<table width ="100%">
<tr class ="styleTrI ">
<td class ="stylePane9 ">
关心指数</td>
<td class ="stylePaneC ">
留言人头像</td>
<td class ="stylePane9 ">
留言人姓名</td>
<td class="stylePaneC">
留言主题</td>
<td class ="stylePane9 ">
留言内容</td>
<td class ="stylePaneC ">
留言时间</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class ="styleTrII ">
<td class ="stylePaneC ">
<asp:Label ID="lblUserID" runat="server" Text='<%# Eval("UserID") %>'></asp:Label>
</td>
<td class ="stylePane9 ">
<asp:Image ID="imgHead" runat="server"
ImageUrl='<%# @"~\Uploads\"+Eval("ImageHead") %>' Width="114px"></asp:Image>
</td>
<td class ="stylePaneC ">
<asp:Label ID="lblLeavePetName" runat="server" Text='<%# Eval("PetName") %>'></asp:Label>
</td>
<td class ="stylePane9 ">
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
</td>
<td class ="stylePaneC">
<asp:Label ID="lblMessageContent" runat="server"
Text='<%# Eval("MessageContent") %>' ></asp:Label>
</td>
<td class ="stylePane9 ">
<asp:Label ID="lblUserTime" runat="server" Text='<%# Eval("UserTime") %>'></asp:Label>
</td>
</tr>
</table>
<table width ="100%">
<tr >
<td align="left">
<asp:Panel ID="panelDispear" runat="server" Visible="False">
<asp:TextBox ID="txtReply" runat="server" TextMode="MultiLine" Width="500px" Height ="50px"></asp:TextBox>
</asp:Panel>
<br />
<asp:LinkButton ID="lnkReply" runat="server" CommandName="Reply"
Font-Overline="false">回复</asp:LinkButton>
<asp:LinkButton ID="lnkSubmit" runat="server" CommandName="Submit"
Font-Overline ="false" >提交</asp:LinkButton>
<asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete"
Font-Overline="false">删除</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:DataList>后台部分代码:
protected void DataListMyMessageBoard_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandSource.GetType() == typeof(LinkButton))
{
if (((LinkButton)e.CommandSource).CommandName == "Reply")
{
((Panel )e.Item .FindControl ("panelDispear")).Visible =true;
}
if (((LinkButton)e.CommandSource).CommandName == "Submit")
{
string s = ((TextBox)(((Panel)e.Item.FindControl("panelDispear")).FindControl("txtReply"))).Text.Trim();
Response.Write(s);
}
if (((LinkButton)e.CommandSource).CommandName == "Delete")
{
}
}
}
Panel设置了隐藏属性,点回复按钮时,Panel中的TextBox文本框出现,然后再TextBox中输入文字,点提交的时候,页面为什么不会打出文本框中的字????代码如上图,求高手赐教!!!
!<asp:DataList ID="DataListMyMessageBoard" runat="server" Width="100%"
onitemcommand="DataListMyMessageBoard_ItemCommand">
<HeaderTemplate>
<table width ="100%">
<tr class ="styleTrI ">
<td class ="stylePane9 ">
关心指数</td>
<td class ="stylePaneC ">
留言人头像</td>
<td class ="stylePane9 ">
留言人姓名</td>
<td class="stylePaneC">
留言主题</td>
<td class ="stylePane9 ">
留言内容</td>
<td class ="stylePaneC ">
留言时间</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class ="styleTrII ">
<td class ="stylePaneC ">
<asp:Label ID="lblUserID" runat="server" Text='<%# Eval("UserID") %>'></asp:Label>
</td>
<td class ="stylePane9 ">
<asp:Image ID="imgHead" runat="server"
ImageUrl='<%# @"~\Uploads\"+Eval("ImageHead") %>' Width="114px"></asp:Image>
</td>
<td class ="stylePaneC ">
<asp:Label ID="lblLeavePetName" runat="server" Text='<%# Eval("PetName") %>'></asp:Label>
</td>
<td class ="stylePane9 ">
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
</td>
<td class ="stylePaneC">
<asp:Label ID="lblMessageContent" runat="server"
Text='<%# Eval("MessageContent") %>' ></asp:Label>
</td>
<td class ="stylePane9 ">
<asp:Label ID="lblUserTime" runat="server" Text='<%# Eval("UserTime") %>'></asp:Label>
</td>
</tr>
</table>
<table width ="100%">
<tr >
<td align="left">
<asp:Panel ID="panelDispear" runat="server" Visible="False">
<asp:TextBox ID="txtReply" runat="server" TextMode="MultiLine" Width="500px" Height ="50px"></asp:TextBox>
</asp:Panel>
<br />
<asp:LinkButton ID="lnkReply" runat="server" CommandName="Reply"
Font-Overline="false">回复</asp:LinkButton>
<asp:LinkButton ID="lnkSubmit" runat="server" CommandName="Submit"
Font-Overline ="false" >提交</asp:LinkButton>
<asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete"
Font-Overline="false">删除</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:DataList>后台部分代码:
protected void DataListMyMessageBoard_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandSource.GetType() == typeof(LinkButton))
{
if (((LinkButton)e.CommandSource).CommandName == "Reply")
{
((Panel )e.Item .FindControl ("panelDispear")).Visible =true;
}
if (((LinkButton)e.CommandSource).CommandName == "Submit")
{
string s = ((TextBox)(((Panel)e.Item.FindControl("panelDispear")).FindControl("txtReply"))).Text.Trim();
Response.Write(s);
}
if (((LinkButton)e.CommandSource).CommandName == "Delete")
{
}
}
}
Panel设置了隐藏属性,点回复按钮时,Panel中的TextBox文本框出现,然后再TextBox中输入文字,点提交的时候,页面为什么不会打出文本框中的字????代码如上图,求高手赐教!!!
纯属猜测
应该前台设置STYLE='display:none',这样才能用FindControl找到。
无环境,我记得是这样,你先试试!