473,394 Members | 1,641 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,394 software developers and data experts.

writing asp variabls within javascript blocks

In asp.net 1.1, what is the proper method for writing variables to the aspx
page that are contained within javascript blocks?

example:

<script language="JavaScript">
myJavascriptVariable= <asp:Literal Runat="server"
ID="ltl_sectionsJavascriptVariables"></asp:Literal>;
</script>

ASP.net doesn't like that syntax.

-Darrel
May 24 '06 #1
4 1061
RegisterClientScriptBlock & RegisterStartupScript
See :-http://www.codeproject.com/aspnet/Mayank_Gupta.asp
Hope that helps
Patrick

"Darrel" <no*****@nospam.com> wrote in message
news:u$**************@TK2MSFTNGP03.phx.gbl...
In asp.net 1.1, what is the proper method for writing variables to the
aspx page that are contained within javascript blocks?

example:

<script language="JavaScript">
myJavascriptVariable= <asp:Literal Runat="server"
ID="ltl_sectionsJavascriptVariables"></asp:Literal>;
</script>

ASP.net doesn't like that syntax.

-Darrel

May 24 '06 #2
> RegisterClientScriptBlock & RegisterStartupScript
See :-http://www.codeproject.com/aspnet/Mayank_Gupta.asp
Hope that helps
Patrick


Well, that's a pain. Isn't javascript supposed to be client side? Why stick
it in the codebehind?

Thanks, though!

-Darrel
May 24 '06 #3
MS
hi

use this way ....

<script language="JavaScript">
myJavascriptVariable= <% = serverVariable %>;
</script>

Thanks
Munawar
"Darrel" <no*****@nospam.com> wrote in message
news:u$**************@TK2MSFTNGP03.phx.gbl...
In asp.net 1.1, what is the proper method for writing variables to the
aspx page that are contained within javascript blocks?

example:

<script language="JavaScript">
myJavascriptVariable= <asp:Literal Runat="server"
ID="ltl_sectionsJavascriptVariables"></asp:Literal>;
</script>

ASP.net doesn't like that syntax.

-Darrel

May 26 '06 #4
Hi,

Darrel wrote:
RegisterClientScriptBlock & RegisterStartupScript
See :-http://www.codeproject.com/aspnet/Mayank_Gupta.asp
Hope that helps
Patrick

Well, that's a pain. Isn't javascript supposed to be client side? Why stick
it in the codebehind?

Thanks, though!

-Darrel


I don't get your question.

JavaScript is client-side, but some part of your scripts might depend on
server-side variables. What I do is create JS files with the "pure
client-side code". However, some parts of the code must be created
dynamically on the server (typical example: localized texts), so I add
script lines using RegisterClientScriptBlock.

Eventually, every piece of script added to the page is interpreted and
can be referenced from other piece of script on the same page.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
May 28 '06 #5

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

Similar topics

2
by: Jonathan Dodds | last post by:
In "VBScript and JScript Don't Mix, at least in ASP" <http://blogs.msdn.com/ericlippert/contact.aspx> Eric Lippert wrote: Ideally you want the server side <SCRIPT> blocks to contain only global...
16
by: Java script Dude | last post by:
To all Mozilla JS Guru's (IE dudes welcome), I have spent the last three years developing complex DHTML applications that must work in IE 5.5sp2+ but I use Mozilla 1.3+** to do all my...
2
by: estafford | last post by:
I am having trouble writing a conditional block using ASP.NET and C#. I am trying to do something like this: 1. if page is PostBack - transfer to another page 2. if not postback - connect...
35
by: rbt | last post by:
I've been doing some file system benchmarking. In the process, I need to create a large file to copy around to various drives. I'm creating the file like this: fd = file('large_file.bin', 'wb')...
3
by: alsu50 | last post by:
Hello All, I have a user control which has an ASP.Net dropdown, gets filled up from database, and is supposed to open a document when the selected index is changed. The control itself is usually...
6
by: Dan | last post by:
Excuse me if i'm being a bit thick here, but is it possible to reference a server side variable within an embedded js source file. For example, my test.js file contains alert('<%=tmpVar%>'); ...
22
by: Christopher Nelson | last post by:
I have a little menu system which essentially takes HTML like: <div id='foo'></div> and retrieves foo.shtml from the server and inserts it inside the <div>. But sometimes I'd like foo.shtml...
5
by: Tomislav | last post by:
Hello, I tried to use "javascript:return confirm();" function in following manner ( triggered by form onSubmit event ): ** <form method="post" action="mail.php" onSubmit="javascript:return...
1
by: Lobo | last post by:
I'm wondering how expensive and (in)efficient is to use Collection type javascript library functions (similar to using Blocks), instead of repeating the 'for' iterator over and over across a large...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
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,...
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
tracyyun
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...

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.