I add a JavaScript event handler to some of my Webcontrols using the
Attributes.Add( ) method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);"
TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator
(&&). However, ASP.NET renders this as && in the code that is
output, even though it is intended to be client-side JavaScript, not a
visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&ev ent.keyCode<=90 );"
I am using VB.NET to write my server-side code, and am using Visual Studio
..NET 2003 with .NET 1.1. Thanks in advance for any help you can give.
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/ 8 2313
Abstractly speaking .innerHTML or .innerText might solve the problem (?)
I just don’t know specifically where you can and/or want to try .innerText
or .innerHTML.
More of a general answer sorry I wish I had more time to look at it.
"Nathan Sokalski" wrote: I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add( ) method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
I am using VB.NET to write my server-side code, and am using Visual Studio ..NET 2003 with .NET 1.1. Thanks in advance for any help you can give. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
I don't think that either of those are part of the solution, because they
refer to the stuff between the opening and closing tags, like the following:
<HTMLTAG>innert ext or innerhtml</HTMLTAG>
My goal is to add an attribute to the tag, which would be like the
following:
<HTMLTAG ATTRIBUTE="ATTR IBUTEVALUE"></HTMLTAG>
Using the Attributes.Add( ) method that I showed in my initial posting adds
the attribute to the right place, but it replaces the ATTRIBUTEVALUE' s &'s
with &'s, therefore causing the JavaScript to have incorrect syntax.
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Sean" <Se**@discussio ns.microsoft.co m> wrote in message
news:A5******** *************** ***********@mic rosoft.com... Abstractly speaking .innerHTML or .innerText might solve the problem (?)
I just don't know specifically where you can and/or want to try .innerText or .innerHTML.
More of a general answer sorry I wish I had more time to look at it. "Nathan Sokalski" wrote:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add( ) method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
I am using VB.NET to write my server-side code, and am using Visual Studio ..NET 2003 with .NET 1.1. Thanks in advance for any help you can give. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
Ah..I see, yeah I have no idea either. Its clear that you have a clear
understanding what I was getting at and also how it doesnt apply to your
situation.
sorry about that.
"Nathan Sokalski" wrote: I don't think that either of those are part of the solution, because they refer to the stuff between the opening and closing tags, like the following:
<HTMLTAG>innert ext or innerhtml</HTMLTAG>
My goal is to add an attribute to the tag, which would be like the following:
<HTMLTAG ATTRIBUTE="ATTR IBUTEVALUE"></HTMLTAG>
Using the Attributes.Add( ) method that I showed in my initial posting adds the attribute to the right place, but it replaces the ATTRIBUTEVALUE' s &'s with &'s, therefore causing the JavaScript to have incorrect syntax. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Sean" <Se**@discussio ns.microsoft.co m> wrote in message news:A5******** *************** ***********@mic rosoft.com... Abstractly speaking .innerHTML or .innerText might solve the problem (?)
I just don't know specifically where you can and/or want to try .innerText or .innerHTML.
More of a general answer sorry I wish I had more time to look at it. "Nathan Sokalski" wrote:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add( ) method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
I am using VB.NET to write my server-side code, and am using Visual Studio ..NET 2003 with .NET 1.1. Thanks in advance for any help you can give. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
Well, I haven't found a way to do it using ONLY the Attributes.Add( ) method
yet (if there is one, it might be unavoidable depending on how they coded
the Add() method), but I think I figured out a workaround that I think will
work for all situations. Rather than doing:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);"
TextBox2.Attrib utes.Add("onKey Press", jscode)
I will do the following:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);"
Page.RegisterCl ientScriptBlock ("TextBox2_Rest rictInput", "<script
type=""text/javascript"">fu nction TextBox2_Restri ctInput(){" & jscode &
"}</script>")
TextBox2.Attrib utes.Add("onKey Press", "return TextBox2_Restri ctInput();")
This basically writes my JavaScript code as a function, and then I just
return the value returned by the function. Apparently
RegisterClientS criptBlock leaves the &'s alone, so it works. Maybe this is
how ASP.NET intended all generated JavaScript to be added, although I think
it would be nice to be able to do it without the RegisterClientS criptBlock
method, but I guess I'll have to deal with it this way for now.
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Sean" <Se**@discussio ns.microsoft.co m> wrote in message
news:CA******** *************** ***********@mic rosoft.com... Ah..I see, yeah I have no idea either. Its clear that you have a clear understanding what I was getting at and also how it doesnt apply to your situation.
sorry about that.
"Nathan Sokalski" wrote:
I don't think that either of those are part of the solution, because they refer to the stuff between the opening and closing tags, like the following:
<HTMLTAG>innert ext or innerhtml</HTMLTAG>
My goal is to add an attribute to the tag, which would be like the following:
<HTMLTAG ATTRIBUTE="ATTR IBUTEVALUE"></HTMLTAG>
Using the Attributes.Add( ) method that I showed in my initial posting adds the attribute to the right place, but it replaces the ATTRIBUTEVALUE' s &'s with &'s, therefore causing the JavaScript to have incorrect syntax. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Sean" <Se**@discussio ns.microsoft.co m> wrote in message news:A5******** *************** ***********@mic rosoft.com... > Abstractly speaking .innerHTML or .innerText might solve the problem > (?) > > I just don't know specifically where you can and/or want to try > .innerText > or .innerHTML. > > More of a general answer sorry I wish I had more time to look at it. > > > > "Nathan Sokalski" wrote: > >> I add a JavaScript event handler to some of my Webcontrols using the >> Attributes.Add( ) method as follows: >> >> >> Dim jscode as String = "return >> (event.keyCode> =65&&event.keyC ode<=90);" >> TextBox2.Attrib utes.Add("onKey Press", jscode) >> >> >> You will notice that jscode contains the JavaScript Logical And >> operator >> (&&). However, ASP.NET renders this as && in the code that is >> output, even though it is intended to be client-side JavaScript, not a >> visible onscreen character. How can I get ASP.NET to output >> >> >> onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);" >> >> instead of >> >> onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);" >> >> >> I am using VB.NET to write my server-side code, and am using Visual >> Studio >> ..NET 2003 with .NET 1.1. Thanks in advance for any help you can give. >> -- >> Nathan Sokalski >> nj********@hotm ail.com >> http://www.nathansokalski.com/ >> >> >>
Server.HTMLDeco de("&&" )
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l... I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add () method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&ev ent.keyCode<=90 );"
I am using VB.NET to write my server-side code, and am using Visual Studio .NET 2003 with .NET 1.1. Thanks in advance for any help you can give. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Nathan Sokalski" <nj********@hot mail.com> wrote in
news:#O******** ******@tk2msftn gp13.phx.gbl: I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add( ) method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&ev ent.keyCode<=90 );"
I am using VB.NET to write my server-side code, and am using Visual Studio .NET 2003 with .NET 1.1. Thanks in advance for any help you can give.
Nathan,
I think your solution of using Page.RegisterCl ientScriptBlock is
about the only reasonable thing that will work.
I used Reflector to trace thru
System.Web.UI.W ebControlsWebCo ntrol.Attribute s to see if it was doing
any kind of encoding. It turns out that
System.Web.Http Utility.HtmlAtt ributeEncode is called on any text
added via Attributes.Add. As you've found out, HtmlAttributeEn code
turns & into &. It also turns double quotes (") into ".
--
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
That would return the String && which is what I am currently putting in. The
conversion to && occurs somewhere between the call to
Attributes.Add( ) and the time that the page is sent to the browser. The
problem is that I don't know where, and if I did, I am not sure it is an
area of code that I have the ability to edit, because I think it is in some
area of the code that is part of ASP.NET, and I therefore do not have access
to the source code. I do still want to find a way to output characters
without having them go through what I think is the Server.HtmlEnco de()
method, but I have found a reasonably simple workaround for doing what I was
trying to do that caused me to start this thread (see the message I posted
at 2/28/2006 7:32 PM for the workaround I found)
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Scott M." <s-***@nospam.nosp am> wrote in message
news:e2******** ******@TK2MSFTN GP09.phx.gbl... Server.HTMLDeco de("&&" )
"Nathan Sokalski" <nj********@hot mail.com> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l...I add a JavaScript event handler to some of my Webcontrols using the Attributes.Ad d() method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&ev ent.keyCode<=90 );"
I am using VB.NET to write my server-side code, and am using Visual Studio .NET 2003 with .NET 1.1. Thanks in advance for any help you can give. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
Yup, I don't think there is any easy solution save the
workaround you used. Frankly, I think they got this
one wrong in ASP.NET. It does the html encoding
automatically on that method call. The only other
workaround I can think of is to use methods of the HtmlTextWriter
and simply write the whole element without the
encoding turned on. That's not as easy to pull off as your workaround
and may need a custom control.
The correct way for ASP.NET to have done this would've been to at least
turn off html encoding when "javascript :" is prepended to the text, or
better
yet, another parameter in that method for the encoding, just like one of the
overloads of the AddAttribute method of the HtmlTextWriter.
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:OM******** ******@TK2MSFTN GP14.phx.gbl... That would return the String && which is what I am currently putting in.
The conversion to && occurs somewhere between the call to Attributes.Add( ) and the time that the page is sent to the browser. The problem is that I don't know where, and if I did, I am not sure it is an area of code that I have the ability to edit, because I think it is in
some area of the code that is part of ASP.NET, and I therefore do not have
access to the source code. I do still want to find a way to output characters without having them go through what I think is the Server.HtmlEnco de() method, but I have found a reasonably simple workaround for doing what I
was trying to do that caused me to start this thread (see the message I posted at 2/28/2006 7:32 PM for the workaround I found) -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Scott M." <s-***@nospam.nosp am> wrote in message news:e2******** ******@TK2MSFTN GP09.phx.gbl... Server.HTMLDeco de("&&" )
"Nathan Sokalski" <nj********@hot mail.com> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l...I add a JavaScript event handler to some of my Webcontrols using the Attributes.Ad d() method as follows:
Dim jscode as String = "return (event.keyCode> =65&&event.keyC ode<=90);" TextBox2.Attrib utes.Add("onKey Press", jscode)
You will notice that jscode contains the JavaScript Logical And
operator (&&). However, ASP.NET renders this as && in the code that is output, even though it is intended to be client-side JavaScript, not a visible onscreen character. How can I get ASP.NET to output
onKeyPress="ret urn (event.keyCode> =65&&event.keyC ode<=90);"
instead of
onKeyPress="ret urn (event.keyCode> =65&&ev ent.keyCode<=90 );"
I am using VB.NET to write my server-side code, and am using Visual Studio .NET 2003 with .NET 1.1. Thanks in advance for any help you can give. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Prodip Saha |
last post by:
Dear ASP.NET Gurus,
I have a TextBox control with AutoPostBack set to true to execute the server
scripts. I also, added some client script for validation.What I want
is--execute the client script and if the cleint script returns true only
then I want to execute the server scripts. Am I asking too much or is it
achievable? Please don't give me...
|
by: Ben |
last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control
for setting the page size. I can get the control into the pager inside the
datagrid itemcreated event by checking for ListItemType.Pager. The problem
I'm having is subscribing to the selectedindex changed event. The datagrid
doesn't even seem fire an itemcommand,...
|
by: sianan |
last post by:
I tried to use the following example, to add a checkbox column to a
DataGrid in an ASP.NET application:
http://www.codeproject.com/aspnet/datagridcheckbox.asp
For some reason, I simply CAN'T get the example to work. I created the
following two classes, provided with the example:
*-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn...
|
by: Nathan Sokalski |
last post by:
I have a VB.NET function that I am using in an ASP.NET page. The code
creates a String, which contains && (the JavaScript Logical AND operator)
and is used as part of the JavaScript sent to the browser. However, ASP.NET
is converting this to & even though it is intended to be part of the
JavaScript. This is causing my JavaScript not to work...
|
by: Nathan Sokalski |
last post by:
I add a JavaScript event handler to some of my Webcontrols using the
Attributes.Add() method as follows:
Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"
TextBox2.Attributes.Add("onKeyPress", jscode)
You will notice that jscode contains the JavaScript Logical And operator
(&&). However, ASP.NET renders this as...
| |
by: rincewind |
last post by:
I remember reading an article (was it Herb Sutter's?) that recommended
avoiding using directives. While I quite understand this recommendation
for headers, what's wrong in using directive in .cpp files?
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted
********************************************************
For this teeny job, please refer to:
http://feeds.reddit.com/feed/8fu/?o=25
|
by: Nathan Sokalski |
last post by:
I am adding an onmouseover attribute using the Attributes.Add() method, and
the String I am using for the value contains the & character. However, when
rendered the & is converted to the HTML representation of & which causes
my JavaScript not to work. What can I do to prevent the Add() method from
modifying my value? Thanks.
--
Nathan...
|
by: =?Utf-8?B?R1ROMTcwNzc3?= |
last post by:
Hi All,
I have a neat little script that calculates price based on quantity without
refreshing the page.. the script is -
<script type="text/javascript">
function OpenWin(url)
{
window.open(url,'win','scrollbars=1,status=0,resizable=0,width=200,height=265');
}
|
by: RN1 |
last post by:
Consider the following code:
------------------------------
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
If Not (Page.IsPostBack) Then
'binding data from DB to the Repeater
End If
End Sub
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
| |
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...
| |