Subject: mailto: in ManageUsers.aspx
Posted By: spardoe Post Date: 8/17/2006 7:26:39 AM
Mailto in the gridview in ManageUser.aspx doesn't seem to be working as shown in the book (p.172) or in the downloaded code.

<asp:HyperLinkField HeaderText="E-mail" DataTextField="Email" DataNavigateUrlFormatString="mailto:{0}" DataNavigateUrlFields="Email" />

A search on Google suggested that we need to use a templatefield instead:

<asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("Email") %>' NavigateUrl='<%# Eval("Email", "mailto:{0}") %>' />
                </ItemTemplate>
</asp:TemplateField>


Any comments?

Reply By: MythicalMe Reply Date: 8/17/2006 2:17:51 PM
I'm not sure in what context the template field for your Googled source is used, so I won't comment on it. Google is probably not a good source because you don't know if the person posting is using ASP.Net 1.1 or 2.0 and frankly anyone can put up a webpage with totally false and/or misleading information. Perhaps the use of MSDN and the help files in Visual Studio are a better and more trustworthy sources.

Having used this code 3 times suggests that the problem is within your code. What is the nature of your problem?

Reply By: spardoe Reply Date: 8/22/2006 8:34:28 AM
I am using the downloaded code.

In ManageUser.aspx there is a HyperLinkField containing a mailto. In the gridview this should make the user's email address clickable, however it does not. Replacing the HyperLinkField with a TemplateField makes it work.
Am I to assume it is working for you? Does anyone else have this problem?


Reply By: saille Reply Date: 1/23/2007 9:34:15 PM
I also have the same problem, both in the sample code downloaded from this site and with my own code based on the book.

Reply By: saille Reply Date: 1/23/2007 9:38:22 PM
...and I can confirm spardoe's solution fixed it too.

Reply By: saille Reply Date: 1/23/2007 9:40:04 PM
... not sure if it makes any difference, but I am using Visual Web Developer 2005, not Visual Studio 2005.

Reply By: fedejico Reply Date: 5/24/2007 11:50:06 AM
I think DataNavigateUrlFormaString="mailto:{0}" doesn't work because of the ":" character, which has a special meaning in format strings. It certainly doesn't work as provided in the downloable code.
As a side note, I believe this issue has something to do with localization. Localization is always a pain in the back when it comes to codeless databinding, where .NET assumes (quite wrongly, and there's an issue open at MS about it to be tackled at future Visual Studio Releases) all DateTime values passed as InputParameters to ObjectDataSources are in Invariant format. That format happens to be mm/dd/yyyy, which makes dd/mm/yyyy codeless databound datetime fields to cause an error when inserting/updating.

Go to topic 39236

Return to index page 1