在asp:按钮上将变量作为mailto主体发送

时间:2014-04-23 10:43:49

标签: html asp.net mailto

我有一个网站,我希望用户能够通过电子邮件分享链接。此特定页面是移动版本。

我有一个使用mailto的asp:按钮,我需要从页面传递变量以在电子邮件正文中构建URL。

 <asp:Button ID="btnEmail" runat="server" Width="70%"  Text="Share Property" PostBackUrl='<%#"mailto:?subject=Check out this property at xxx - " & DataBinder.Eval(Container, "DataItem.PropertyName") & "body=" & DataBinder.Eval(Container, "DataItem.PropertyID")%>'/>

mailto正在运行,主题正在填充,但邮件正文似乎包含页面的视图状态:

__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTM4ODYwNDQ2Mg9kFgJmD2QWAgIDD2QWAmYPZBYCAgEPFgIeC18hSXRlbUNvdW50AgEWAmYPZBYKAgEPFgIeCWlubmVyaHRtbAXCAzx1bCBjbGFzcz0nc2xpZGVzJz48bGk%2BPGltZyBzcmM9Jy4uL2Z0cC9wQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwLzYtQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwLzctQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwLzgtQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwL2FCUkFOQ0hfUDEzNDEuanBnJyAvPjwvbGk%2BPGxpPjxpbWcgc3JjPScuLi9mdHAvYkJSQU5DSF9QMTM0MS5qcGcnIC8%2BPC9saT48bGk%2BPGltZyBzcmM9Jy4uL2Z0cC9jQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwL2RCUkFOQ0hfUDEzNDEuanBnJyAvPjwvbGk%2BPGxpPjxpbWcgc3JjPScuLi9mdHAvZUJSQU5DSF9QMTM0MS5qcGcnIC8%2BPC9saT48L3VsPmQCAg8VBRpSZWR3b29kIENsb3NlLCBTb3V0aCBPeGhleQM2NzUDUENNBVAxMzQxnwFPbmUgYmVkcm9vbSB0b3AgZmxvb3IgZmxhdCB3aXRoIGZpdHRlZCBiYXRocm9vbSwgZml0dGVkIGtpdGNoZW4gd2l0aCB3YXNoaW5nIG1hY2hpbmUsIGZyaWRnZSwgY29va2VyIGFuZCBtaWNyb3dhdmUuICBBdmFpbGFibGUgbm93IGZ1cm5pc2hlZC4gIEVuZXJneSBSYXRpbmcgRS5kAgMPDxYCHgtQb3N0QmFja1VybAUlaHR0cDovL21hcHMuYXBwbGUuY29tL21hcHM%2FcT1XRDE5IDZTRWRkAgUPDxYCHwIFHFJlcXVlc3RWaWV3aW5nLmFzcHg%2FSUQ9UDEzNDFkZAIHDw8WAh8CBWNtYWlsdG86P3N1YmplY3Q9Q2hlY2sgb3V0IHRoaXMgcHJvcGVydHkgYXQgSm9obiBXaGl0ZW1hbiAtIFJlZHdvb2QgQ2xvc2UsIFNvdXRoIE94aGV5Ym9keT10ZXN0UDEzNDFkZGQlH8aveHqM96GJK6rcUKFtYormuw%3D%3D&__PREVIOUSPAGE=jXBhZExXbPAJGCoKEgVxPvQrYIK2wX4xu1Pu8m0He281&__EVENTVALIDATION=%2FwEWBQLLnPHNBQKLm%2B%2BxDQKTlZGGAQKbi8jQCALB16nOAksIgJxExXvoFLdOr%2FT%2F56iiVmxW&ctl00%24MainContent%24myDataRepeater%24ctl00%24btnEmail=Share+Property

我哪里错了?

1 个答案:

答案 0 :(得分:1)

Button想要进行回发,其中包含所有表单字段。

您还可以使用<a href="mailto:...">从用户的邮件程序发起电子邮件。你在这里不需要runat=server

您可以将该链接设置为看起来像按钮。