473,809 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about Asp.Net/Javascript

Someone refresh my memory.

Assuming you are limited to VS 2005, ASP.Net, Javascript, and no Ajax (and
no 3rd party controls), is there any way to use Javascript to shift between
multiple pages of data without postback? (i.e. something equivalent to tab
controls?)

(i.e. I thought hiding a component using javascript 'tightened up' the
layout but I just realized that's not so. I may be mistakenly thinking of a
previous job where we did use 3rd party controls.)
Jul 28 '08 #1
6 1313
B. Chernick wrote:
Someone refresh my memory.

Assuming you are limited to VS 2005, ASP.Net, Javascript, and no Ajax (and
no 3rd party controls), is there any way to use Javascript to shift between
multiple pages of data without postback? (i.e. something equivalent to tab
controls?)

(i.e. I thought hiding a component using javascript 'tightened up' the
layout but I just realized that's not so. I may be mistakenly thinking of a
previous job where we did use 3rd party controls.)
Yes, you can easily show and hide elements.

Example:

<script type="text/javascript">

function $(id) { return document.getEle mentById(id); }

function show(index) {
var items = [$('item1'),$('i tem2'),$('item3 ')];
for (var i=0; i<items.length ; i++) {
items[i].style.display = i==index ? 'block' : 'none';
}
return false;
}

</script>

<a href="#" onclick="return show(0);">1</a>
<a href="#" onclick="return show(1);">2</a>
<a href="#" onclick="return show(2);">3</a>

<div id="item1" style="display: block">Item 1</div>
<div id="item2" style="display: none">Item 2</div>
<div id="item3" style="display: none">Item 3</div>

--
Göran Andersson
_____
http://www.guffa.com
Jul 28 '08 #2
Thanks. I'm going to have to try this but frankly, the syntax looks a little
strange to me. I'm not sure I understand what I'm seeing. What I've been
doing is more like this:
var t = document.getEle mentById("F0006 ");
t.style.visibil ity='hidden';

The problem is that even though the table is hidden, it's still taking up
space.

"Göran Andersson" wrote:
B. Chernick wrote:
Someone refresh my memory.

Assuming you are limited to VS 2005, ASP.Net, Javascript, and no Ajax (and
no 3rd party controls), is there any way to use Javascript to shift between
multiple pages of data without postback? (i.e. something equivalent to tab
controls?)

(i.e. I thought hiding a component using javascript 'tightened up' the
layout but I just realized that's not so. I may be mistakenly thinking of a
previous job where we did use 3rd party controls.)

Yes, you can easily show and hide elements.

Example:

<script type="text/javascript">

function $(id) { return document.getEle mentById(id); }

function show(index) {
var items = [$('item1'),$('i tem2'),$('item3 ')];
for (var i=0; i<items.length ; i++) {
items[i].style.display = i==index ? 'block' : 'none';
}
return false;
}

</script>

<a href="#" onclick="return show(0);">1</a>
<a href="#" onclick="return show(1);">2</a>
<a href="#" onclick="return show(2);">3</a>

<div id="item1" style="display: block">Item 1</div>
<div id="item2" style="display: none">Item 2</div>
<div id="item3" style="display: none">Item 3</div>

--
Göran Andersson
_____
http://www.guffa.com
Jul 29 '08 #3
"B. Chernick" <BC*******@disc ussions.microso ft.comwrote in message
news:69******** *************** ***********@mic rosoft.com...
var t = document.getEle mentById("F0006 ");
t.style.visibil ity='hidden';

The problem is that even though the table is hidden, it's still taking up
space.
Yes, it will still take up space if you use the above syntax...

If you want to do it properly, you'll need something like:

t.style.display ="none";

to make it invisible, or

t.style.display ="block";

to make it visible again...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 29 '08 #4
I'm still a bit confused. I've never heard of that 'block' value.

However this seems to do what I want:

t = document.getEle mentById("F0005 ");
t.style.display ='none';
var t = document.getEle mentById("F0006 ");
t.style.visibil ity='visible';

(Table F0005 vanishes and Table F0006 moves up to it's place.)

More testing tomorrow.... Thanks.
"Mark Rae [MVP]" wrote:
"B. Chernick" <BC*******@disc ussions.microso ft.comwrote in message
news:69******** *************** ***********@mic rosoft.com...
var t = document.getEle mentById("F0006 ");
t.style.visibil ity='hidden';

The problem is that even though the table is hidden, it's still taking up
space.

Yes, it will still take up space if you use the above syntax...

If you want to do it properly, you'll need something like:

t.style.display ="none";

to make it invisible, or

t.style.display ="block";

to make it visible again...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 29 '08 #5
B. Chernick wrote:
Thanks. I'm going to have to try this but frankly, the syntax looks a little
strange to me. I'm not sure I understand what I'm seeing.
Yes, the syntax might look a bit strange if you are not used to it.

Another way of writing the show function, that you may be more familiar
with, could be:

function show(index) {

var items = new Arra();
items[0] = document.getEle mentById('item1 ');
items[1] = document.getEle mentById('item2 ');
items[2] = document.getEle mentById('item3 ');

for (var i=0; i<items.length ; i++) {
if (i==index) {
items[i].style.display = 'block';
} else {
items[i].style.display = 'none';
}
}

return false;
}

What I've been
doing is more like this:
var t = document.getEle mentById("F0006 ");
t.style.visibil ity='hidden';

The problem is that even though the table is hidden, it's still taking up
space.
Yes, that's how the visibility attribute works. It shows or hides an
element, but it still takes up space in the document flow all the time.

The display attribute controls how the element behaves in the document
flow. The value 'block' makes it behave like a div element, the value
'inline' makes it behave like a span element, and the value 'none'
removes it from the document flow entirely.

As you probably want one page at the time to be visible, and the other
pages totally out of the way, the display attribute is a better option
than the visibiliy attribute.

--
Göran Andersson
_____
http://www.guffa.com
Jul 29 '08 #6
"B. Chernick" <BC*******@disc ussions.microso ft.comwrote in message
news:EB******** *************** ***********@mic rosoft.com...

[top-posting corrected]
>>var t = document.getEle mentById("F0006 ");
t.style.visib ility='hidden';

The problem is that even though the table is hidden, it's still taking
up
space.

Yes, it will still take up space if you use the above syntax...

If you want to do it properly, you'll need something like:

t.style.displa y="none";

to make it invisible, or

t.style.displa y="block";

to make it visible again...

I'm still a bit confused. I've never heard of that 'block' value.
http://www.google.co.uk/search?sourc...+display+block
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 29 '08 #7

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

Similar topics

3
6171
by: Randell D. | last post by:
Folks, I'm still learning javascript - I've invested in a couple of books and reading online as much as possible. I'm pretty sure what I am suggesting is possible though I'm trying to weigh up the faults that might go with the suggestion... all opinions welcome. My question: I have a list of links that go to pages that have a similar layout. Could I have a text swap, similar to what I've seen with image swaps (or an image switch)...
5
1350
by: Henry | last post by:
HTML is an acronym for Hyper Text Markup Language. But why is it hyper? Too much java . . . http://takeoff.to/henry
2
1729
by: Mark Preston | last post by:
Its perhaps a bit early to ask, since I'm still doing the page design and haven't got down to the coding yet, but I wonder if anyone can help with a bit of a question. To lay the groundwork, a quick description of the template design for the pages:- 1. There will be a body section of the page consisting of a set of <div> layers. The top level layers will all have the same CSS class to ensure a common design look. 2. At the side or top...
2
8407
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
3
1272
by: Diana M | last post by:
Hello, I have started my first asp.net application (beginner). I have 2 text boxes on the form that should contain 2 different dates (beginning and end). It would be nice to have 2 small buttons besides each text box that allow to open little form with calendar. I came from VB world where we had arrays of controls, but here I can't make it. Should I have 2 controls with different names and write code twice in the button click event or...
1
2157
by: google1 | last post by:
Has anyone written this one? Seen such a thing? Please send me a link: Skill Testing Question Exploder --------------------------------------------- Basically the plan is to create the javascript powered form one can surf to to bypass cheating via Window calculator for Skill Testing Question tests. One simply copys the Skill Testing Question from the Contest Webpage
5
5663
by: Joh | last post by:
I'm using mailto to open up an email that have a hyperlink in the body. The hyperlink passes two variables Name and Emailadress. The problem is that only the first variable Name show up in the hyperlink. It seems that javascript takes the & as the end of the body where I use it to separate my variables. Anyone know how to deal with this? "<script...
1
1117
Frinavale
by: Frinavale | last post by:
Hi there! I'm not sure if this question should be posted under the .NET form or the JavaScript form...I just have a general question about JavaScript and .NET. I usually test my JavaScript in static web pages before adding it to my .NET application and I've noticed that if I manually create a static web page that uses JavaScript and then try to run it with Internet Explorer, Internet Explorer "blocks" my JavaScript content. When I...
6
1568
by: John | last post by:
Hello, I was thinking of trying out JavaScript and learn it on my own. I had a few questions though. Is it still popular with businesses today? Is JavaScript bad for search engine opt. (SEO)?
3
2559
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div class="not-required-question"><p>Question Text</p><input /></div>
0
9721
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...
1
10378
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,...
0
9198
agi2029
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...
1
7653
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
6881
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();...
0
5550
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...
1
4332
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
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
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.