I have a div whose innerHtml is set in my c# code (.cs).
<div id="feedbackRow" runat="server"></div>
.cs
feedbackRow.InnerHtml = "Activate your account to access reward points and unlock deals, discounts and bigger savings!.</br>You will find an ACTIVATE link within the body of the email.If you did not recevied the email into your inbox then please check your spam folders. </br>Thanks again for using ABC";
Here I want to make bold "ACTIVATE" word or say some of the text should be in different color/font in above statement. How do I do that?
You could place the text you want to be bolded between <b> or <strong> tags.
<b>text</b>
or
<strong>text</strong>
maybe simple html:
feedbackRow.InnerHtml = "<strong>Activate</strong> ..."
Related
Is there a way i can add below css as inline css using C# from codebehind
CSS
.slide .btn_six::after {
content: " ECHNOLOGY";
}
HTML
<div class="slide">
<a target="_blank" href="#" class="post-badge btn_six">T</a>
</div>
I have to list multiple articles and each article belongs to a category and each category i have to show in an animated manner where only first caharacter of word will be visible and when user hovers over it it then reveal whole category name as shown in template link.
I want to do this using C# from the codebehind file itself as it will be easy
I looked for example but could not find any relevant example
Can't be done.
A hover event is only possible to do from the client side with JavaScript or by using CSS :hover selector. While it could be possible to wire it up to send a request back to the server to write a segment of HTML and then replace the HTML element in JavaScript, this would not be very practical. It is much simpler just to write the class on the client side without making a round trip to the server or better yet, just set a CSS :hover and be done with it.
I have a contenteditable div the user enter data. When they enter line break, each browser stores the data differently. When I export this data to Word using HtmlToOpenXml it adds a blank line for the content and I want to avoid that so the html page and word doc look the same.
One option for me is to replace the tags <br>, <div>, <p> with blank and then replace the </div> and </p> with <br/> in the C# code using RegEx. But I do not know what all formatting is used for contenteditable div by different browsers and this implementation may not help.
I would like to know what is the best way to address this or is there any open source tool/dll that helps me with this issue?
e.g. ContentEditable div actual data in browsers looks like below
Chrome -
line1<div>line2</div><div>line3</div>
IE Edge-
<div>line1</div><div>line22</div><div>line3<br></div>
FireFox - I read it uses <p> </p> instead of <div> </div>
Safari - ????
A Solution I found:
You could use RegEx, which I highly recommend in C# for parsing information.
Then effectively based on the formatting you could narrow down what browser it is and then move on towards parsing it's output and what its XML means universally. This will not be easy but no cross-platform ever truly is. I would give a example of how this could be done, but RegEx in all honesty takes a good amount of work and it would be quite a bit of code to make a example that could show you how to parse it and find out what the browser is.
For making an existing site to multilingual, I follow globalization technique, I have created 3 resource files for different content like label & header text file, grid header text file etc...
Now I have two keys in different resource files i.e Email and Message, at a third place I want to show both these keyword together i.e Email message. Do I need to create third key or I can concatenate already existing keys. Currently I am using below two codes
For showing directly on page:
HttpContext.GetGlobalResourceObject("ResourceLabelButton", "Email")
For showing as text of any control like Textbox, label:
Text ="<%$ Resources:ResourceContent, Email %>"
I can concatenate two resource string on .cs page but it will increase timeline, so please suggest so I can only change on .aspx pages.
Thanks in advance
ASP.NET tag attribute values that use <%$ Something: Something Else %> are of a special syntax called ASP.NET Expressions. Using them as attribute values are pretty much all-or-nothing; there's no way to add any code into the ASPX file to manipulate what those expressions evaluate to. You'll have to do this in the code-behind.
You should create a separate resource entry for "Email Message" instead of concatenating "Email" and "Message". To understand why, look at Spanish:
Email = Correo electrónico
Message = Mensaje
Simple concatenation gives you Correo electrónico Mensaje. This is wrong. The correct translation is:
Email Message = Mensaje de correo electrónico
Notice that in the translation, the order of "Email" and "Message" has been reversed, and a new word (de, which means "of") has been inserted between them.
On the other hand, look at the translations for "New Message" and "Last Message":
New Message = Mensaje nuevo
Last Message = Último mensaje
As you can see, there are complex rules that govern when to reverse the order of words and when to insert de. These rules, of course, are different in other languages.
So in general, you should never concatenate localized words or phrases to form a longer phrase.
Always provide a separate resource entry for every phrase.
I was having the same issue, and I solved it by using this option instead:
<asp:Label id="lbl1" runat="server" Text="Email: <%= HttpContext.GetGlobalResourceObject("ResourceContent", "Email") %>">
For local Resources, use the GetLocalResourceObject method instead of GetGlobalResourceObject
If this value is being used very often make a third key for the same, else concatenate at runtime
Try with the below code
<asp:Label ID="lblNameAndNos" runat="server">
<%= ""+ Resources.Resources.Name + "/" + Resources.Resources.Nos %>
</asp:Label>
Instead of using inside Text property use the above way
I am dealing with a situation where I should change the font of a HTML body in C sharp using a stylesheet.
I have added a stylesheet to my project with name Stylesheet1.css which contains the code to change the font of a HTML body.
body {
font-size: 10px;
}
I need to reference this stylesheet in source code, where I am processing the HTML body.
I am processing the HTML body as follows.
if(some condition)
{
mail.HTMLBody= ? ? ? ? ;
}
I need to reference the stylesheet in this part. How can I do this?
I would not use external stylesheets for emails. As alot of email clients do not support it.
See http://groundwire.org/support/articles/css-and-email-newsletters
and
http://www.alistapart.com/articles/cssemail/
As some clients like hotmail remove the 'body' tag all togeather so your example in your question will not work. So you can instead wrap your email in a DIV and use inline styles so you get best support for all email clients.
A list of what is supported by which client is here http://css-discuss.incutio.com/wiki/Style_In_Email
Edit
You should be able to set the font-size like this
<div style="font-size:10px;">
your email content here
<p style="font-size:14px;">
some bigger text
</p>
</div>
I agree with Daveo's answer - you are best off embedding styles directly rather than linking out to an external CSS
There is a very, very extensive matrix of styles & features that are and aren't supported by the popular email apps (outlook/gmail/yahoo mail/etc) at http://www.campaignmonitor.com/css/
http://htmlemailboilerplate.com/ is a really good starting point for getting html and css right in emails.
I have a textbox as follows:
<asp:TextBox runat="server" ID="txtOtherApps" Height="400" Width="400"
TextMode="MultiLine" ontextchanged="txtOtherApps_TextChanged" ></asp:TextBox>
How to display link in this textbox?
The TextBox allows you to display text which the user can edit. It does not allow you to display anything but plain text. To display a URL in the TextBox, simply set its Text property:
txtOtherApps.Text = "http://www.example.com/";
It wont, however, be a "link". Clicking the URL will cause a text cursor to be placed, allowing for the user to edit the URL.
It is possible if you use JavaScript
Use JavaScript on your text element - such that:
<input type="text" name="t1" id="t1" value="http://www.google.com" onmouseover="this.style.cursor='pointer' ;" onClick="window.open(this.value);"/>
Only Java script can do what you are asking for.
You won't be able to click on the link, but you can just set the Text property of the TextBox to the URL.
ASP.NET will render TextBoxes as textareas (in your case, because it's multiline) or inputs. These are standard HTML fragments which are just plain text containers. You can style them, but you can't really linkify the contents of them.
If you really just want to put the text of a link into a box, do this:
// either from the server:
txtOtherApps.Text = YourLinkString;
// or from the client:
<script>
document.getElementById('<%=txtOtherApps.ClientID%>').value = YourJsLinkValue;
</script>
If you want something to happen with the user clicks on the text area, you can add an onclick handler to it...but this would be weird.
You will need a RichTextBox. The .NET one is not available for web applications, but there are a few third party solutions available.
http://www.richtextbox.com/ is one of them, you will have to see for yourself if there is any available that suits your needs better.