When using databinding, I have gotten into the habit of using single quotes
(apostrophe) round attribute values rather than double quotes because this
allows visual studio to work when there are quotation marks in the
databinding expression. As far as I can tell this seems to be recommended
practice.
However, I just realised that HtmlEncode doesn't encode apostrophes, so if
you do something like this
<a href=... title='<%#Serve r.HtmlEncode(Da taBinder.Eval(C ontainer,
"DataItem.FullN ame"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
Assuming not, does this mean I have to write my own version of HtmlEncode?
TIA
Andy 4 4683
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:OB******** *****@TK2MSFTNG P15.phx.gbl... When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are quotation marks in the databinding expression. As far as I can tell this seems to be recommended practice.
"Recommende d" might be pushing things a bit. <g> It works, but consistently
using double quotes to wrap attributes will generally make your HTML a bit
easier to maintain.
However, I just realised that HtmlEncode doesn't encode apostrophes,
But it will encode the double quote character, so things would be a bit
easier if you were wrapping with double quotes.
so if you do something like this
<a href=... title='<%#Serve r.HtmlEncode(Da taBinder.Eval(C ontainer, "DataItem.FullN ame"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
You can do it, but it will require a bit more work.
Assuming not, does this mean I have to write my own version of HtmlEncode?
You should really do this anyway in order to facilitate handling of other
"interestin g" scenarios (e.g.: encoding of text to be used as a literal
string in client-side javascript). The easiest way to implement this is to
call the provided HtmlEncode method, then massage the resulting string as
required for its intended used. TIA
Andy
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:OB******** *****@TK2MSFTNG P15.phx.gbl... When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are quotation marks in the databinding expression. As far as I can tell this seems to be recommended practice.
"Recommende d" might be pushing things a bit. <g> It works, but consistently
using double quotes to wrap attributes will generally make your HTML a bit
easier to maintain.
However, I just realised that HtmlEncode doesn't encode apostrophes,
But it will encode the double quote character, so things would be a bit
easier if you were wrapping with double quotes.
so if you do something like this
<a href=... title='<%#Serve r.HtmlEncode(Da taBinder.Eval(C ontainer, "DataItem.FullN ame"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
You can do it, but it will require a bit more work.
Assuming not, does this mean I have to write my own version of HtmlEncode?
You should really do this anyway in order to facilitate handling of other
"interestin g" scenarios (e.g.: encoding of text to be used as a literal
string in client-side javascript). The easiest way to implement this is to
call the provided HtmlEncode method, then massage the resulting string as
required for its intended used. TIA
Andy
After writing my own HtmlEncode method, I realised that ' is not part
of the HTML 4 standard and also IE does not support it.
I conclude that it is not possible to use single quotes round attribute
values if the attribute value could itelf contain a single quote mark (i.e.
apostrophe). It seems unfortunate that so many examples use this style.
"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:e6******** ********@TK2MSF TNGP09.phx.gbl. .. "Andy Fish" <aj****@blueyon der.co.uk> wrote in message news:OB******** *****@TK2MSFTNG P15.phx.gbl... When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are quotation marks in the databinding expression. As far as I can tell this seems to be recommended practice.
"Recommende d" might be pushing things a bit. <g> It works, but consistently using double quotes to wrap attributes will generally make your HTML a bit easier to maintain.
However, I just realised that HtmlEncode doesn't encode apostrophes,
But it will encode the double quote character, so things would be a bit easier if you were wrapping with double quotes.
so if you do something like this
<a href=... title='<%#Serve r.HtmlEncode(Da taBinder.Eval(C ontainer, "DataItem.FullN ame"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
You can do it, but it will require a bit more work.
Assuming not, does this mean I have to write my own version of HtmlEncode?
You should really do this anyway in order to facilitate handling of other "interestin g" scenarios (e.g.: encoding of text to be used as a literal string in client-side javascript). The easiest way to implement this is to call the provided HtmlEncode method, then massage the resulting string as required for its intended used.
TIA
Andy
Try using ' instead of '.
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:uJ******** ******@TK2MSFTN GP15.phx.gbl... After writing my own HtmlEncode method, I realised that ' is not part of the HTML 4 standard and also IE does not support it.
I conclude that it is not possible to use single quotes round attribute values if the attribute value could itelf contain a single quote mark (i.e. apostrophe). It seems unfortunate that so many examples use this style.
"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message news:e6******** ********@TK2MSF TNGP09.phx.gbl. .. "Andy Fish" <aj****@blueyon der.co.uk> wrote in message news:OB******** *****@TK2MSFTNG P15.phx.gbl... When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are quotation marks in the databinding expression. As far as I can tell this seems to be recommended practice.
"Recommende d" might be pushing things a bit. <g> It works, but consistently using double quotes to wrap attributes will generally make your HTML a bit easier to maintain.
However, I just realised that HtmlEncode doesn't encode apostrophes,
But it will encode the double quote character, so things would be a bit easier if you were wrapping with double quotes.
so if you do something like this
<a href=... title='<%#Serve r.HtmlEncode(Da taBinder.Eval(C ontainer, "DataItem.FullN ame"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
You can do it, but it will require a bit more work.
Assuming not, does this mean I have to write my own version of HtmlEncode?
You should really do this anyway in order to facilitate handling of other "interestin g" scenarios (e.g.: encoding of text to be used as a literal string in client-side javascript). The easiest way to implement this is to call the provided HtmlEncode method, then massage the resulting string as required for its intended used.
TIA
Andy
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Foreman |
last post by:
I've got a set of emails in a table, where sometimes they've failed to
input the @ properly.
Eg james.foreman'abcmail.co.uk
How do I write a replace to deal with that?
Also, I've got a set of names in a table, all in lower case. I can
easily capitalise the first letter of each name, but if it's somebody
like O'Brien, I'd like to get that right too (so need to be able to
|
by: Richard Hollenbeck |
last post by:
I have an email field and a command button to send email. The
problem is that when the email program opens up there are
apostrophes around the email address that I have to manually
remove before sending the email. My code is very simple. I
can't understand why the apostrophes are put there but the
addresses won't work until they are stipped of the apostrophes.
Here's my code:
Private Sub cmdEmail_Click()
If len(txtEmail) > 0 Then
|
by: Andrea Williams |
last post by:
I have a class that imports System.Web.UI.Page. The code below works:
public string JScriptEncode(string strValue)
{
strValue = strValue.Replace(@"'", "\x27"); //' JScript encode apostrophes
strValue = strValue.Replace(@"""", "\x22"); //' JScript encode double-quotes
|
by: Michael Gaillez |
last post by:
Hi,
I'm dynamically loading an assembly into an ASP.NET application. In the
control that I load from that dynamic assembly I've tried to use
Server.HTMLEncode but this results in a serious performance loss. Is there
anyone who knows why or is there an alternative for server.htmlencode
method? Without the server.htmlencode the thingy works very fine.
greetz
|
by: David Lozzi |
last post by:
Howdy,
I have my left navigation of Hyperlinks, and part of the link's querystring
is the title of the page they are going to. For example, one of the pages is
Cars & Trucks. With HtmlEncode, it translates it to Cars%20&%20Trucks. The
ampersand is still there. Shouldn't the HtmlEncode translate that? So on the
page the title is Cars because its translating the & as a new name/value
pair. Any suggestions?
Thanks!
| |
by: Marco Miltenburg |
last post by:
While working on some multilingual code I found a rather strange thing
happening with Server.HTMLEncode.
While loading different languages I change the Codepage and Charset in
ASP to reflect the language. This all works fine. However when I tried
to use Charset UTF-8 with Codepage 65001 everywhere I found that
HTMLEncode always translates all UTF-8 characters to &#xxxx.
Example:
|
by: Alexander Higgins |
last post by:
>>Thanks for the response....
Point Taken but this is not the case. Thus, if a person writes a text
file on her or his computer and does not use UNICODE to save it, the
current code page is used. If this file is given to someone with some
other current codepage, the file is not displayed correctly. Simply
converting the file to Unicode will make the data display properly.
When performing the encoding process the encoding will escape...
|
by: Lucanos |
last post by:
Hey Guys,
Probably a simple question, but one I am struggling with all the same.
I know that in PHP you wrap a text string in apostrophes or quotations
- (examples $variable = 'this string' OR $variable = "that string" ).
What I am trying to figure is how to handle a string which contains
both apostrophes and quotations already. Is there a something like
CDATA is for XML?
|
by: =?Utf-8?B?bXVzb3NkZXY=?= |
last post by:
Hi
I'm trying to code up an admin system for my website. A couple of the
welcome text paragraphs are stored in an SQL database, so that we can update
them should we need to. However, even though I'm using the HTMLEncode method
(I've also tried the URLEncode method), the apostrophe always remains, and
then when I try and do the update query, I get...
Unclosed quotation mark after the character string
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |