PDA

View Full Version : RichTextBox


nature
10-11-2004, 05:42 AM
When using RichTextBox to create the body of an email, I can't get it to correctly include links to my own site (www.sociables.org). It wants to do a relative link. See below.

Here's the HTML before sending:

<P><A href="http://discountasp.net/support.aspx">http://discountasp.net/support.aspx</A></P>
<P><A href="http://www.sociables.org/aboutus/faqAboutUs.aspx">http://www.sociables.org/aboutus/faqAboutUs.aspx</A></P>

Here's the HTML it actually sends:
<p><a href="http://discountasp.net/support.aspx">http://discountasp.net/support.aspx</a></p>
<p><a href="/aboutus/faqAboutUs.aspx">/aboutus/faqAboutUs.aspx</a></p>

nature
10-12-2004, 06:32 AM
Here's the code. For all it's worth, I'm using webmatrix to develop the pages.

<%@ Page Language="VB" validaterequest="false" %>
<%@ Register TagPrefix="RTB" Namespace="RichTextBoxControl" Assembly="RichTextBox, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=17b15412cfbf13c1" %>
<script runat="server">

' Insert page code here

sub page_load()

txtEmail.text = "carl@sociables.org"
txtName.text = "carl"

RichTextBox1.ButtonImagePath = "/images/standard"

if not ispostback then
pnlMsg.visible = true
pnlThanks.visible = false
end if
End Sub


Sub btnSend_Click(sender As Object, e As EventArgs)
' Build a MailMessage
Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mailMessage.From = txtEmail.text
mailMessage.To = "carl@sociables.org"
mailMessage.Subject = dropSubject.SelectedItem.text
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html
mailMessage.Body = RichTextBox1.text System.Web.Mail.SmtpMail.SmtpServer = "localhost"
System.Web.Mail.SmtpMail.Send(mailMessage)
pnlMsg.visible = false
pnlThanks.visible = true
End Sub

</script>

<html>
<head>
<title>Example Tabs</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

</head>

<form runat="server">

<h2>Contact Us
</h2>
<!-- outer shell table -->
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td valign="top" width="20%">
<!-- 1st column --></td>
<td valign="top">
<!-- 2nd column -->
<asp:Panel id="pnlMsg" runat="server">
<table height="150" width="300">
<tbody>
<tr>
<td>
Name</td>
<td>
<asp:TextBox id="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="rvalName" runat="server" ErrorMessage="Please enter your name" ControlToValidate="txtName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Email Address</td>
<td>
<asp:TextBox id="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="rvalEmail" runat="server" ErrorMessage="Please enter your Email address" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
[b]
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Email!" ControlToValidate="txtEmail" ValidationExpression="\S+@\S+\.\S{2,3}"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
Subject:</td>
<td>
<asp:DropDownList id="dropSubject" runat="server">
<asp:ListItem Text="Questions about the Sociables" selected="true" />
<asp:ListItem Text="Report a Problem with the site" />
<asp:ListItem Text="Feedback on the newsletter" />
<asp:ListItem Text="Offer to help" />
<asp:ListItem Text="Exchange links" />
<asp:ListItem Text="Other Subject" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Your message</td>
<td>
[b]<RTB:RichTextBox id="RichTextBox1" runat="server"></RTB:RichTextBox> </td>
</tr>
<tr>
<td></td>
<td>
<asp:Button id="btnSend" onclick="btnSend_Click" runat="server" Text="Send"></asp:Button>
<asp:RequiredFieldValidator id="rvalBody" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="RichTextBox1">Please enter your message</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</asp:Panel>
<!-- Insert content here -->
<asp:Panel id="pnlThanks" runat="server">Thanks for contacting us! We'll get back to
you as soon as we can. We're all volunteers doing this in our "spare"
time, so it may not be right away.</asp:Panel>
</td>
<td valign="top" width="20%">
<!-- third column --></td>
</tr>
</tbody>
</table>
<!-- Insert content here -->
</form>
</body>
</html>


[b]quote:Originally posted by bruce

Very weird... so it only does this on your domain.

Can you post the code?


[b]quote:Originally posted by nature

When using RichTextBox to create the body of an email, I can't get it to correctly include links to my own site (www.sociables.org). It wants to do a relative link. See below.

[b]Here's the HTML before sending:

<P><A href="http://discountasp.net/support.aspx">http://discountasp.net/support.aspx</A></P>
<P><A href="http://www.sociables.org/aboutus/faqAboutUs.aspx">http://www.sociables.org/aboutus/faqAboutUs.aspx</A></P>

Here's the HTML it actually sends:
<p><a href="http://discountasp.net/support.aspx">http://discountasp.net/support.aspx</a></p>
<p><a href="/aboutus/faqAboutUs.aspx">/aboutus/faqAboutUs.aspx</a></p>
</blockquote id="quote"></font id="quote">

B.

DiscountASP.NET
http://www.DiscountASP.NET

</blockquote id="quote"></font id="quote">

bruce
10-12-2004, 11:57 AM
Very weird... so it only does this on your domain.

Can you post the code?


quote:Originally posted by nature

When using RichTextBox to create the body of an email, I can't get it to correctly include links to my own site (www.sociables.org). It wants to do a relative link. See below.

[b]Here's the HTML before sending:

<P><A href="http://discountasp.net/support.aspx">http://discountasp.net/support.aspx</A></P>
<P><A href="http://www.sociables.org/aboutus/faqAboutUs.aspx">http://www.sociables.org/aboutus/faqAboutUs.aspx</A></P>

Here's the HTML it actually sends:
<p><a href="http://discountasp.net/support.aspx">http://discountasp.net/support.aspx</a></p>
<p><a href="/aboutus/faqAboutUs.aspx">/aboutus/faqAboutUs.aspx</a></p>
</blockquote id="quote"></font id="quote">

B.

DiscountASP.NET
http://www.DiscountASP.NET

Aristotle
10-13-2004, 12:27 PM
Richtextbox does this on purpose. See this article on their site for explanation:

http://richtextbox.mykb.com/Article_F4495.aspx

You can disable it using the HtmlOutputChangeAbsoluteURLsToRelative property.