473,775 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with ASP.Net 2.0 and JavaScript

OK,

Im working with a DataList in .Net 2.0, the code shows the list when
the query has executed. I have the page feature in its own div and
display:none so its not visible until the list shows. Ive written
javascript in ASP.Net to show the DIV. The code is as follows:
jScript = "<script LANGUAGE=""java script"">" & vbNewLine
jScript = jScript & "function ToggleDiv(id){" & vbNewLine
jScript = jScript & "var elem = document.getEle mentById(id);" &
vbNewLine
jScript = jScript & "if (elem)" & vbNewLine
jScript = jScript & "{" & vbNewLine
jScript = jScript & " if (elem.style.dis play != 'block')" &
vbNewLine
jScript = jScript & " {" & vbNewLine
jScript = jScript & " elem.style.disp lay = 'block';"
&vbNewLine
jScript = jScript & " elem.style.visi bility = 'visible';"
& vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & " else" & vbNewLine
jScript = jScript & " {" & vbNewLine
jScript = jScript & " elem.style.disp lay =
'none';" & vbNewLine
jScript = jScript & " elem.style.visi bility =
'hidden';" & vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & "}" & vbNewLine
jScript = jScript & "ToggleDiv('Pag e_Div');" & vbNewLine
jScript = jScript & "</sc" & "ript>"
Response.Write( jScript)
I dont get any errors, but the javascript doesn't execute either.
Anyone have any ideas?

Jul 27 '06 #1
3 1546
<ri*****@psycho coder.netwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
I dont get any errors, but the javascript doesn't execute either.
Anyone have any ideas?
I'm not a VB.NET specialist, but what happens if you replace vbNewLine with
"\n"
Jul 27 '06 #2

I think you gotta register it with the page (or are you not showing that
part?)

here is a sample I had ... written in vb.net

its actually a part of a class, where the constructor has the Page ... so I
can reuse it.

that's what _currentPage is all about.
I'd get a basic thing working first.. ( just an alert or something?) before
dealing with the hidden div stuff.


Private Sub CreateTrimJS()

Dim sb As StringBuilder = New StringBuilder

sb.Append("<!-- " & vbCrLf)
sb.Append("func tion trim(str) {" & vbCrLf)

''http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20959311.ht
ml

''sb.Append("al ert('got to trim function -->' + str);" &
vbCrLf)

sb.Append("var returnVal='';" & vbCrLf)

sb.Append("retu rnVal=str.repla ce(/^\s*|\s*$/g,"""");" &
vbCrLf)

''debug
''sb.Append("al ert('str -->*' + str + '*\nreturnVal--*' +
returnVal + '*');" & vbCrLf)
sb.Append("retu rn returnVal;" & vbCrLf)

''close the entire function
sb.Append("}" & vbCrLf)
sb.Append(vbCrL f & "// -->" & vbCrLf)


If (Not
_currentPage.Is StartupScriptRe gistered("someu niquevalueHere" )) Then
'prevents a "double register"

_currentPage.Re gisterStartupSc ript("someuniqu evalueHere", sb.ToString)
End If

End Sub


<ri*****@psycho coder.netwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
OK,

Im working with a DataList in .Net 2.0, the code shows the list when
the query has executed. I have the page feature in its own div and
display:none so its not visible until the list shows. Ive written
javascript in ASP.Net to show the DIV. The code is as follows:
jScript = "<script LANGUAGE=""java script"">" & vbNewLine
jScript = jScript & "function ToggleDiv(id){" & vbNewLine
jScript = jScript & "var elem = document.getEle mentById(id);" &
vbNewLine
jScript = jScript & "if (elem)" & vbNewLine
jScript = jScript & "{" & vbNewLine
jScript = jScript & " if (elem.style.dis play != 'block')" &
vbNewLine
jScript = jScript & " {" & vbNewLine
jScript = jScript & " elem.style.disp lay = 'block';"
&vbNewLine
jScript = jScript & " elem.style.visi bility = 'visible';"
& vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & " else" & vbNewLine
jScript = jScript & " {" & vbNewLine
jScript = jScript & " elem.style.disp lay =
'none';" & vbNewLine
jScript = jScript & " elem.style.visi bility =
'hidden';" & vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & "}" & vbNewLine
jScript = jScript & "ToggleDiv('Pag e_Div');" & vbNewLine
jScript = jScript & "</sc" & "ript>"
Response.Write( jScript)
I dont get any errors, but the javascript doesn't execute either.
Anyone have any ideas?

Jul 27 '06 #3
This works fine for me. However, It DOESN'T work if your div is AFTER
this block, it doesn't exist in the dom when you call the function with
the line:

ToggleDiv('Page _Div');

If your div is before this block, it works fine.

I advise putting the whole function in a .js file and including it into
your web page in a <scripttag between the <head.. </headsection.
That will make it easier to read/debug. I'd then put the
"ToggleDiv('Pag e_Div');" call in the onload event of the <bodytag.
That way, no matter where the DIV exists, IE will only call your toggle
function once the entire page is loaded into the DOM.

ri*****@psychoc oder.net wrote:
OK,

Im working with a DataList in .Net 2.0, the code shows the list when
the query has executed. I have the page feature in its own div and
display:none so its not visible until the list shows. Ive written
javascript in ASP.Net to show the DIV. The code is as follows:
jScript = "<script LANGUAGE=""java script"">" & vbNewLine
jScript = jScript & "function ToggleDiv(id){" & vbNewLine
jScript = jScript & "var elem = document.getEle mentById(id);" &
vbNewLine
jScript = jScript & "if (elem)" & vbNewLine
jScript = jScript & "{" & vbNewLine
jScript = jScript & " if (elem.style.dis play != 'block')" &
vbNewLine
jScript = jScript & " {" & vbNewLine
jScript = jScript & " elem.style.disp lay = 'block';"
&vbNewLine
jScript = jScript & " elem.style.visi bility = 'visible';"
& vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & " else" & vbNewLine
jScript = jScript & " {" & vbNewLine
jScript = jScript & " elem.style.disp lay =
'none';" & vbNewLine
jScript = jScript & " elem.style.visi bility =
'hidden';" & vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & " }" & vbNewLine
jScript = jScript & "}" & vbNewLine
jScript = jScript & "ToggleDiv('Pag e_Div');" & vbNewLine
jScript = jScript & "</sc" & "ript>"
Response.Write( jScript)
I dont get any errors, but the javascript doesn't execute either.
Anyone have any ideas?
Jul 27 '06 #4

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

Similar topics

13
40765
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
3
2220
by: Curious Angel | last post by:
Help? Spec Character Problems w/JAVASCRIPT TOOLTIP Hi, I'm experiencing bizarre problems with quote marks that previously displayed properly in a Javascript TOOLTIP I wrote a year ago . . . and now, inexplicably, won't translate (?). The COPYRIGHT text was originally written using Typographers Quotes (in the ALT-0145, ALT-0146, ALT-0147, and ALT-0148 family). For those who don't know what I'm talking about, these are the more stylized...
0
2366
by: Linda Antonsson | last post by:
Hi, I am trying to put together a CSS-based layout consisting of a header, a sidebar and a main content area. Page: http://www.westeros.org/ASoWS/ CSS: http://www.westeros.org/ASoWS/ASoWS-All.css (the relevant IDs are towards the bottom) JS: http://www.westeros.org/ASoWS/SetHeight.js
3
1740
by: Mark Morton | last post by:
I'm writing an if statement for a UK credit card form validation script. Users who specify that their card is Switch need to enter either the issue number or the 'valid from' date. I'm trying to write an if statement so that if: 1. The word "Month" is in the validFromMonth field (where they haven't selected a month a the drop-down menu) or the word "Year" is in the validFromYear field (where they haven't selected a year another the...
55
4214
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems with this sort of thing? I know some of these potential users are with big companies and am wondering if anyone had real problems with that.
13
3258
by: nick4soup | last post by:
General advice wanted: Some web sites (including two large companies in Australia) get themselves awfully confused if the user presses the BACK button in their browser (and possibly the forward button). They are using ASP (or some other active script), but I presume it's possible to make the same mistakes in CGI, or PHP, for instance. Questions:
2
4064
by: Jeronimo Bertran | last post by:
A couple of questions I am having problems with converting my JavaScript to C#. I have the following code using JavaScript for the mouseover handler that works fine: <SCRIPT language=JavaScript> function MyMouseOver() {
3
4488
by: PCgeek | last post by:
sorry moved this over to javascript forum, didn't mean to post 2x! Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and so that the music doesn't reload each time a page is switched. There is another javascript to resize...
11
1593
by: vortex93 | last post by:
hello, i have IE 6 and all the things that need for java in Security Settings are Enable and i still have problems with java like: when i want to open a window that have javascript as link it's not works... or like, i want to download a file that i need to enter a code that need java it's not work too..
10
1854
by: jodleren | last post by:
Hi I know, that there are a lot of people having problems with orkut.com, errors like "object expected" and named objects missing. When loading the site can generate some 10 errors, and still just leave a blue page - seems like it heavily rely on JS. Still, me and friends having problems and orkut seems just to ignore it. I am sure, that other poeple have problems, and I really wonder what
0
9622
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, 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...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
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, 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...
0
10107
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9916
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 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...
1
7464
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6718
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();...
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2853
bsmnconsultancy
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...

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.