I'm trying to do a password recovery with SMTP. In the email, i've added some necessary text and hyperlink for the user to recover their password. As you can see the code here, i've added a hyper link.
strBody.Append("Click here to change your password.");
In order to add a non-hyperlink text, i added this statement behind the code.
strBody.Append("Click here to change your password. \t\t\t\t This is a computer generated email for your password recovery. \t\t please do not reply this email.");
I've added a \t in the string but instead it doesn't show any tab spacing in the email. What have i done wrong here?
The fact that you have HTML in your body makes me assume that you are sending HTML emails. If this is the case then your tabs will be in the source but HTML collapses all whitespace which includes tabs.
You'll have to either use proper HTML to indent your text (eg margins on block elements) or use plain text where tabs and such like will work.
There are no tabs in HTML. That \t is a Windows character code. You'll need to either throw a <span style="margin-left: 1em;"> around the text or use (many times).
I think the right approach is this:
<span style=\"margin-left: 1em;\">This is a computer generated email for your password recovery.</span>
use multiple times instead of tabs in your html message body.
You're probably sending the email as HTML, therefore the tab (\t) will be rendered as a single space, which is normal.
Either change the email format normal (plain text) or add styling to mimic the indentation you want.
Tab characters inside <pre></pre> tags seem to survive.
I have not tried this in an e-mail yet, but you can give it a shot.
<pre>
a b c d
</pre>
Related
I'm trying to encode data that is to be displayed on a separate page (.aspx) after a user submits a form with their information and questions. There are both text input and textarea fields that the user can fill out.
I'm using the <%#: %> expression to place this data on the page since it does the HTML encoding, but have run into an issue with the encoding also encoding the br tags as text instead of actual line breaks.
Is there a way to make it so that the br tags still cause a line break, but leave everything else encoded using this method?
Example of user input:
Hi
This is what should be responded with.
Here is an example of the code that places it on the page:
<p><%#: ((DiscussionThread.Discussion)Container.DataItem).Text %></p>
What it currently displays on the page:
Hi<br /><br />This is what should be responded with.
Thanks in advanced!
Don't know, will it help you in your case or no, but I always use next way:
string forInput = yourTextBoxID.Text.ToString().Replace(Environment.NewLine, "%NL%");
string forOutput = forInput.Replace("%NL%", Environment.NewLine);
If in forOutput Environment.NewLine will not work, change it to <br />
%NL% it is just a identificator, u may change to anything else.
I'm currently working to solve a major permanent XSS vulnerability on my website. To do this, I am calling:
this.Title = System.Security.SecurityElement.Escape(this.Title);
On the values I am taking in, which properly escapes all of the characters that need to be escaped (<, >, &, etc.). My problem arises when I go to display this title elsewhere in my page:
<p> #title </p>
Which displays the string exactly as it appears, such as "< ;> ;, etc.".
To solve this problem, I have noticed that if I call:
<p> #html.raw(title) </p>
That the values are properly displayed on the page (<, >, etc.). But I am afraid that this still ensures a vulnerability. What is the best way to properly render the html onto the page? Am I doing anything wrong? Or am I properly using html.raw()?
You want to take and store the title as is comes in. Then you escape the title on output.
See answer on e.g. html/XSS escape on input vs output
I am using default asp.net ToolTip property, the text is
This is Going to be a long text
Thats why we decided to split it.
but using <br/> to split the line doesn't work, it renders as a text, and I want it to break the line instead.
Here is my code:
Label lblActionText = new Label();
lblActionText.Text = "Helloooo Phaltu";
lblActionText.Style.Add("cursor", "pointer");
lblActionText.ToolTip =
"This is Going to be a long text"
+ "<br/>"
+ "Thats why we decided to split it.";
I've not tried this but would "System.Environment.NewLine" not do the job instead of the BR tag?
You can use this to insert a line break inside a ToolTip.
lblActionText.ToolTip = " First text " + Environment.NewLine + " second text ";
Use the line break character entity (
). It is easy to implement but the only problem is that this will work in IE & Chrome but not Firefox.
lblActionText.ToolTip = "This is Going to be a long text
Thats why we decided to split it.";
See jsFiddle: http://jsfiddle.net/jafLf/
You are passing a string value to a Tooltip, and that's why the HTML element <br /> is not working.
However you can try this ASP.Net AJAX TooltipExtender
This works only on IE but other browsers are not!!
If you want to have a customize tooltip then seach for jQuery tooltips to have a formatted tooltip
You can do this with adding a table in the tooltip :)
Example: ASP forum
The ASP.NET ToolTip property corresponds to the HTML title attribute.
In IE and Chrome you can simply do:
<span title="multiline
tool
tip">Mouseover me!</span>
However, that won't work in Firefox as it actually follows the W3C guidelines for CDATA.
CDATA is a sequence of characters from
the document character set and may
include character entities. User
agents should interpret attribute
values as follows:
Replace character entities with characters,
Ignore line feeds,
Replace each carriage return or tab with a single space.
Your best bet (considering you also want to change the colour) would be to go with a jQuery solution such as QTip which gives you all the customisation you want and more..
You cannot change the color of a tooltip with the default title attribute. For that the only way is to use a javascript generated tooltip.
There are plenty of plugins for jQuery such as:
Dynamic tooltip
Popup Bubble
jQuery Horizontal Tooltips
Coda Popup Bubble
Awesomeness
TipTip
(mb)Tooltip
vTip
jGrowl
jQuery Ajax Tooltip
Digg-style post sharing tool with jQuery
Input Floating Hint Box
Simpletip
qTip
Orbital Tooltip
And many more, check them here: Stylish jQuery Tooltip Plugins Webdesign
You can also just create your own using javascript. Add a mouseover event on the element then show a hidden div over the element with whichever html elements you want, in whichever color you need.
It is also more safe to use a javascript approach for cross-browser compatibility.
These spaces are not added by me on HTML SIDE and i cannot edit HTML
I want to know what should my comparison string?
I am using watin to automate website testing process but I am unable to encounter only one button.Every other works
watin searches content by name /values /id and many more and works fine but when i see the value of the submit button that i need to be clicked it has some breaks &nsbp so i think they are playing some role
Here is the html:
<span class='button'><input type="submit" value=" Login " /></span>
<span class='button'><input type="button" value=" Back " onclick="history.back(-1)" /></span>
and here is the code to search
browser.Button(WatiN.Core.Find.ByValue(" Login ")).Click();
what can be done??
-- Suggestion -- (i.e. too big for a comment)
You shouldn't use to add spaces to the submit button. Rather, you should use CSS to style the button to your liking. So you would have something like:
input[type=button] {
padding:10px;
min-width: 150px;
}
By the same token, this could eliminate any of the issues you're having with selecting the button. It could be an issue of encodings breaking with watin and as a result, doing this with CSS will make debugging the issue much cleaner and much easier.
Edit:
Have you tried searching by ID as opposed to by value? ID's are supposed to be unique on a page, so if it doesn't find it by those means, then that's one issue that can be rules out. It could also be the fact that you're searching for a button. A <button> is not the same as a <input type="button">.
Edit 2: Even though the issue was due to encodings breaking, I still recommend you reset that button to reset the text (removing all the non breaking spaces) and attach an id/name to it. The reason being for internationalization purposes - and if for some reason you modify the size of the button in the designer, or i18n the app and the text is different, your test will break.
You shouldn't use entities with WatiN.
This code will work, but you have to use real non-breaking space character:
browser.Button(
WatiN.Core.Find.ByValue(
" Login ")).Click();
This is probably inconvenient, but you could use (after adding reference to System.Web) HttpUtility class:
browser.Button(
WatiN.Core.Find.ByValue(
System.Web.HttpUtility.HtmlDecode(
" Login "))).Click();
But, if I were you, I would just go with Regex:
browser.Button(
WatiN.Core.Find.ByValue(
new Regex(#"^\s*Login\s*$"))).Click();
or even new Regex("Login").
Interesting thing: If you ever will have to Find.ByText you don't have to bother so much, and you can use regular space (ie. not exactly non-breaking space). That's because native IE IHTMLElement::getAttribute (http://msdn.microsoft.com/en-us/library/aa752280(VS.85).aspx) converts from innertext attribute to regular spaces, but from value, id etc. it doesn't ( are converted to real non-breaking spaces - 0xA0)
Wow, you really like spaces! I would remove those and use padding/margins like html was designed to be used. Then you wont need all those spaces and you can assign a proper value to your button which watiN will recognize.
I think it is because the in the HTML source is actually an escaped version of the special character that represents a none breaking space. So in you C# source, you'll probably need that character instead of the html entity code. I think you can find the code of that character by using this button to submit a GET form. It will show the escaped character code in the url.
Of course it is better not to put the spaces in there at all. You should give the button a padding using CSS instead.
I am developing SMS portal in asp.net c# where people register & send sms.
I M Using multiline asp:textbox for input message. i want to break line where user hit enter/new line in textbox. help me if there any textboxeditor which support only <br/> or any other solutions.
from my own experience the default asp:textbox control with TextBoxMode=MultiLine; which automatically adds \r\n for line breaks will do the trick and no additional edit is needed
and html tags like </br> is not processed .
Use textarea tag and escape text on the server side. Replace each line break with </br>, but other tags show as plain text or add some validation.