我需要在邮件中发送使用转发器获得的表格,是否有关于如何在邮件正文中嵌入转发器的示例?我正在使用 MailMessage 发送邮件。我试图实现这个例子:
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
MyRepeater.RenderControl(htmlWrite);
string emailContent = stringWrite.ToString();
但有一个错误:
Control ''m_repeater_btn" of type 'LinkButton' must be placed inside a form tag with runat=server.
即使我把标签表单我仍然得到一个错误,我应该怎么把它?
这是我的 asp.net 页面:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ViewMySisters.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:Repeater ID="MyRepeater" runat="server">
<HeaderTemplate>
<table style="border-collapse:collapse; border:1px solid grey;" width="500">
<tr>
<td style="border: 1px solid grey;">firstname</td>
<td style="border: 1px solid grey;">lastname</td>
<td style="border: 1px solid grey;">age</td>
<td style="border: 1px solid grey;">work experienes</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="border: 1px solid grey;"><%# DataBinder.Eval(Container.DataItem, "NAME")%></td>
<td style="border: 1px solid grey;"><%# DataBinder.Eval(Container.DataItem, "FAMILY NAME")%></td>
<td style="border: 1px solid grey;"><%# DataBinder.Eval(Container.DataItem, "AGE")%></td>
<td style="border: 1px solid grey;"><asp:LinkButton ID="btn" runat="server" Text=">>>>" OnCommand="btnDetails_Command" CommandArgument='<%# Eval("ID") %>' /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<br />
<asp:Button ID="sendMail" runat="server" Text="send" OnClick="sendmail_Clicked" />
</asp:Content>