473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Newline detected when add script in C# (ASP.NET)

Hi!

I'm trying to add script to the page and place following code in my ascx
(control):
Page.RegisterClientScriptBlock("adder", "<script>function
doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
eval(document.all.TextBox2.value)}</script>");

It doesn't work giving me all kind of problems...

I suspect the problem is with <> charachters.

How do I go around this problem?

Also, placing this line in code (I use WebMatrix) will mess up all HTML
code??

Thanks!
Nov 17 '05 #1
2 1474
If that is the exact line from your code, then it just has to do with how
your formed your string. You cannot insert a line break in a string in C#.
It should work if you change your code to read:

Page.RegisterClientScriptBlock("adder", "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document .all.TextBox1.value) +
" +
"eval(document.all.TextBox2.value)}</script>");

or, for more readability, I always for my javascript in a temp variable
first. Just kinda hard to read otherwise

string script = "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document .all.TextBox1.value) +
" +
"eval(document.all.TextBox2.value)}</script>"
Page.RegisterClientScriptBlock("adder", script);

either way, both of those should work for you.

-Cliff
"Ivan Demkovitch" <i@a.b> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
Hi!

I'm trying to add script to the page and place following code in my ascx
(control):
Page.RegisterClientScriptBlock("adder", "<script>function
doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
eval(document.all.TextBox2.value)}</script>");

It doesn't work giving me all kind of problems...

I suspect the problem is with <> charachters.

How do I go around this problem?

Also, placing this line in code (I use WebMatrix) will mess up all HTML
code??

Thanks!

Nov 17 '05 #2
I solved problem...

Actually the problem was in "</script>"

Changed to "<" + "/" + "script>" and it works fine now.

Thanks!
"Cliff Harris" <he***@myrealbox.com> wrote in message
news:Ok*************@TK2MSFTNGP11.phx.gbl...
If that is the exact line from your code, then it just has to do with how
your formed your string. You cannot insert a line break in a string in C#. It should work if you change your code to read:

Page.RegisterClientScriptBlock("adder", "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document .all.TextBox1.value) + " +
"eval(document.all.TextBox2.value)}</script>");

or, for more readability, I always for my javascript in a temp variable
first. Just kinda hard to read otherwise

string script = "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document .all.TextBox1.value) + " +
"eval(document.all.TextBox2.value)}</script>"
Page.RegisterClientScriptBlock("adder", script);

either way, both of those should work for you.

-Cliff
"Ivan Demkovitch" <i@a.b> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
Hi!

I'm trying to add script to the page and place following code in my ascx
(control):
Page.RegisterClientScriptBlock("adder", "<script>function
doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
eval(document.all.TextBox2.value)}</script>");

It doesn't work giving me all kind of problems...

I suspect the problem is with <> charachters.

How do I go around this problem?

Also, placing this line in code (I use WebMatrix) will mess up all HTML
code??

Thanks!


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ahmed El Lakani | last post by:
hi all, recently i've installed vs.NET 2003 on my pc which is runing window 2000 pro with sp4, but when i'm trying to create new ASP.NET Web appication i got this messages "Visual Studio .NET...
5
by: chin | last post by:
Hi, I am trying to retrieved the value of the textarea with the newline preserved without having to submit the form to the server. Does anyone knows how to? I tried soft and hard wrap but both...
2
by: Pat Lester | last post by:
First of all......my environment is WinXP, IIS5.1, ASP.NET 1.1, Visual Studio 2003 Ok. I know that I've messed something up but can't seem to put my finger on it. I recently set up my IIS so...
3
by: Kalyan | last post by:
Hi, I am getting error msg "Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1" when I am trying to create a web project from VS 2003. The...
1
by: priyanshu | last post by:
hello all, my pc is running on windows 2000 pro. with sp4 i have installed IIS 5.0 and VS.net 2003 with framework 1.1 successfully.. now when i try to create new asp.net web application it...
2
by: Steve Richter | last post by:
getting this "potentially dangerous Request.Form value was detected" exception with a textbox which I have populated with some source code. I think I am getting the exception when I click OK on...
1
by: Olav | last post by:
Does anyone know what this means? Olav ISAPI 'c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll' reported itself as unhealthy for the following reason: 'Deadlock detected'. For...
6
by: sarah16 | last post by:
Hi, I installed VS.NET and IIS on WinXP, but when I started a new project/existing of ASP.NET Web Application ,it gave an error "visual studio.net has detected that specified web server is not...
0
by: Steve K | last post by:
to this newline when an enter key is detected. Update: I tried adding this code: <code> public PMDDataGridViewTextBoxEditingControl() :base() { this.Multiline = true; } </code>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.