开发者

mailto and literal control together

开发者 https://www.devze.com 2023-03-04 17:10 出处:网络
Is it possible to do this and how? email: <a href=\"\" mailto:\"\"email1\"\"\"> <asp:Literal ID=\"email1\" runat=\"server\" 开发者_开发百科>

Is it possible to do this and how?

email: <a href="" mailto:""email1""">
         <asp:Literal ID="email1" runat="server" 开发者_开发百科>
         </asp:Literal>
       </a> <br />

I try this but when I open outlook it doesn't write anything in TO: section.


If your application is running under .net 3.5;

email:<a href="mailto:<%= Server.HtmlEncode(email1.Text) %>"><asp:Literal Text="info@example.com" ID="Literal1" runat="server"/></a><br/>

If your application is running under .net 4;

email:<a href="mailto:<%: email1.Text%>"><asp:Literal ID="email1" Text="info@example.com" runat="server"/></a><br/>

NOTE:
although you can use the first approach on .net 4 as well, it's better to use the second one in order to avoid so called syntactic noise

hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号