473,396 Members | 2,076 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.

How to achiev these two things.... ...


Copy and paste this code in the HTML section of the page

1. Why I am using hidden varaible here?
Currently user can click on hide/show link. If the application is in display
mode (I mean the hidden data is displayed) and if the user clicks the
button, the post back happens and the user selected display mode will be
gone. To avoid that I am trying to keep the user opted mode using hidden
control and trying to restore the same value after postback. How to do that?

2. Currently this part of my code appears almost at the end of the page
where user has clicked vertical scroll bar to get into this section. After
scrolling down if the clicks the hide/show link the data will be
displayed/hidden but the user will be shown the top of the page. Some thing
like my smart navaigation is not effective. I know I am not posting the page
back when the user clicks on the hide/show link. But how to restore the
vertical postion of the form when the user clicks on hid/show button.

Your comments and suggestions are highly appreciated.

Benjamin
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="HomeTestApp.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
<!--
function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
border="1">
<tr>
<td><a href="#" onclick="hideshow('row5')">Hide Show</a><INPUT
type="hidden" id="hdnRowSts" value="none" name="hdnRowSts"></td>
</tr>
<tr id="row5" style="DISPLAY:none">
<TD>
<asp:Label id="Label1" runat="server">Label1</asp:Label></TD>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">Label2</asp:Label>
<asp:Button id="btnDoPostBack" runat="server"
Text="btnDoPostBack"></asp:Button></td>
</tr>
</TABLE>
</form>
</body>
</HTML>

Nov 19 '05 #1
4 934
Benjamin:
Your 2nd problem can be fixed by changing the <a> tag to:
<a href="javascript:hideshow('row5')">

the problem with yours is that you have an href="#" which means top of page,
so the onlick event fires then the link is followed (to the top of page),
the syntax provided will work in all browsers.
For your first problem I think your on the right track. Store the value in
a hidden field, and toggle it in your codebehind, something like:

function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
document.getElementById("hdnRowSts").value =
document.getElementById(obj).style.display;
}
and in your codebehind, simply putting the following in your page_load
should work:

If Not Request.Form("hdnRowSts") Is Nothing Then
row5.Style.Add("display", Request.Form("hdnRowSts"))
Else
row5.Style.Add("display", "none")
End If
although you might wanna make sure Request.Form("hdnRowSts") is a valid
value...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Benjamin Smith" <Be*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Copy and paste this code in the HTML section of the page

1. Why I am using hidden varaible here?
Currently user can click on hide/show link. If the application is in display mode (I mean the hidden data is displayed) and if the user clicks the
button, the post back happens and the user selected display mode will be
gone. To avoid that I am trying to keep the user opted mode using hidden
control and trying to restore the same value after postback. How to do that?
2. Currently this part of my code appears almost at the end of the page
where user has clicked vertical scroll bar to get into this section. After
scrolling down if the clicks the hide/show link the data will be
displayed/hidden but the user will be shown the top of the page. Some thing like my smart navaigation is not effective. I know I am not posting the page back when the user clicks on the hide/show link. But how to restore the
vertical postion of the form when the user clicks on hid/show button.

Your comments and suggestions are highly appreciated.

Benjamin
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="HomeTestApp.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
<!--
function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
border="1">
<tr>
<td><a href="#" onclick="hideshow('row5')">Hide Show</a><INPUT
type="hidden" id="hdnRowSts" value="none" name="hdnRowSts"></td>
</tr>
<tr id="row5" style="DISPLAY:none">
<TD>
<asp:Label id="Label1" runat="server">Label1</asp:Label></TD>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">Label2</asp:Label>
<asp:Button id="btnDoPostBack" runat="server"
Text="btnDoPostBack"></asp:Button></td>
</tr>
</TABLE>
</form>
</body>
</HTML>

Nov 19 '05 #2
Karl,
Problem 2 got fixed as per your suggestions. Thanks a lot.
Problem 1. I do not understand how one can access the client side Id in a
server side code.
row5.Style.Add("display", Request.Form("hdnRowSts"))
When I put the above code it says variable not declared.
Benjamin

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e3**************@TK2MSFTNGP14.phx.gbl...
Benjamin:
Your 2nd problem can be fixed by changing the <a> tag to:
<a href="javascript:hideshow('row5')">

the problem with yours is that you have an href="#" which means top of page, so the onlick event fires then the link is followed (to the top of page),
the syntax provided will work in all browsers.
For your first problem I think your on the right track. Store the value in a hidden field, and toggle it in your codebehind, something like:

function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
document.getElementById("hdnRowSts").value =
document.getElementById(obj).style.display;
}
and in your codebehind, simply putting the following in your page_load
should work:

If Not Request.Form("hdnRowSts") Is Nothing Then
row5.Style.Add("display", Request.Form("hdnRowSts"))
Else
row5.Style.Add("display", "none")
End If
although you might wanna make sure Request.Form("hdnRowSts") is a valid
value...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Benjamin Smith" <Be*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Copy and paste this code in the HTML section of the page

1. Why I am using hidden varaible here?
Currently user can click on hide/show link. If the application is in

display
mode (I mean the hidden data is displayed) and if the user clicks the
button, the post back happens and the user selected display mode will be
gone. To avoid that I am trying to keep the user opted mode using hidden
control and trying to restore the same value after postback. How to do

that?

2. Currently this part of my code appears almost at the end of the page
where user has clicked vertical scroll bar to get into this section. After scrolling down if the clicks the hide/show link the data will be
displayed/hidden but the user will be shown the top of the page. Some

thing
like my smart navaigation is not effective. I know I am not posting the

page
back when the user clicks on the hide/show link. But how to restore the
vertical postion of the form when the user clicks on hid/show button.

Your comments and suggestions are highly appreciated.

Benjamin
<%@ Page Language="vb" AutoEventWireup="false"

Codebehind="WebForm1.aspx.vb"
Inherits="HomeTestApp.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
<!--
function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
border="1">
<tr>
<td><a href="#" onclick="hideshow('row5')">Hide Show</a><INPUT
type="hidden" id="hdnRowSts" value="none" name="hdnRowSts"></td>
</tr>
<tr id="row5" style="DISPLAY:none">
<TD>
<asp:Label id="Label1" runat="server">Label1</asp:Label></TD>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">Label2</asp:Label>
<asp:Button id="btnDoPostBack" runat="server"
Text="btnDoPostBack"></asp:Button></td>
</tr>
</TABLE>
</form>
</body>
</HTML>


Nov 19 '05 #3
oh..sorry, add runat="server" to the row and declare it as an HtmlTableRow
....thus making it a server-side control :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e3**************@TK2MSFTNGP14.phx.gbl...
Benjamin:
Your 2nd problem can be fixed by changing the <a> tag to:
<a href="javascript:hideshow('row5')">

the problem with yours is that you have an href="#" which means top of page, so the onlick event fires then the link is followed (to the top of page),
the syntax provided will work in all browsers.
For your first problem I think your on the right track. Store the value in a hidden field, and toggle it in your codebehind, something like:

function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
document.getElementById("hdnRowSts").value =
document.getElementById(obj).style.display;
}
and in your codebehind, simply putting the following in your page_load
should work:

If Not Request.Form("hdnRowSts") Is Nothing Then
row5.Style.Add("display", Request.Form("hdnRowSts"))
Else
row5.Style.Add("display", "none")
End If
although you might wanna make sure Request.Form("hdnRowSts") is a valid
value...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Benjamin Smith" <Be*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Copy and paste this code in the HTML section of the page

1. Why I am using hidden varaible here?
Currently user can click on hide/show link. If the application is in

display
mode (I mean the hidden data is displayed) and if the user clicks the
button, the post back happens and the user selected display mode will be
gone. To avoid that I am trying to keep the user opted mode using hidden
control and trying to restore the same value after postback. How to do

that?

2. Currently this part of my code appears almost at the end of the page
where user has clicked vertical scroll bar to get into this section. After scrolling down if the clicks the hide/show link the data will be
displayed/hidden but the user will be shown the top of the page. Some

thing
like my smart navaigation is not effective. I know I am not posting the

page
back when the user clicks on the hide/show link. But how to restore the
vertical postion of the form when the user clicks on hid/show button.

Your comments and suggestions are highly appreciated.

Benjamin
<%@ Page Language="vb" AutoEventWireup="false"

Codebehind="WebForm1.aspx.vb"
Inherits="HomeTestApp.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
<!--
function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
border="1">
<tr>
<td><a href="#" onclick="hideshow('row5')">Hide Show</a><INPUT
type="hidden" id="hdnRowSts" value="none" name="hdnRowSts"></td>
</tr>
<tr id="row5" style="DISPLAY:none">
<TD>
<asp:Label id="Label1" runat="server">Label1</asp:Label></TD>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">Label2</asp:Label>
<asp:Button id="btnDoPostBack" runat="server"
Text="btnDoPostBack"></asp:Button></td>
</tr>
</TABLE>
</form>
</body>
</HTML>


Nov 19 '05 #4
Thanks Karl,
Both of your suggestions helped me.
Benjamin
"Benjamin Smith" <Be*************@hotmail.com> wrote in message
news:Ou*************@TK2MSFTNGP11.phx.gbl...
Karl,
Problem 2 got fixed as per your suggestions. Thanks a lot.
Problem 1. I do not understand how one can access the client side Id in a
server side code.
row5.Style.Add("display", Request.Form("hdnRowSts"))
When I put the above code it says variable not declared.
Benjamin

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e3**************@TK2MSFTNGP14.phx.gbl...
Benjamin:
Your 2nd problem can be fixed by changing the <a> tag to:
<a href="javascript:hideshow('row5')">

the problem with yours is that you have an href="#" which means top of

page,
so the onlick event fires then the link is followed (to the top of page),
the syntax provided will work in all browsers.
For your first problem I think your on the right track. Store the value

in
a hidden field, and toggle it in your codebehind, something like:

function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
document.getElementById("hdnRowSts").value =
document.getElementById(obj).style.display;
}
and in your codebehind, simply putting the following in your page_load
should work:

If Not Request.Form("hdnRowSts") Is Nothing Then
row5.Style.Add("display", Request.Form("hdnRowSts"))
Else
row5.Style.Add("display", "none")
End If
although you might wanna make sure Request.Form("hdnRowSts") is a valid
value...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Benjamin Smith" <Be*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Copy and paste this code in the HTML section of the page

1. Why I am using hidden varaible here?
Currently user can click on hide/show link. If the application is in

display
mode (I mean the hidden data is displayed) and if the user clicks the
button, the post back happens and the user selected display mode will be gone. To avoid that I am trying to keep the user opted mode using hidden control and trying to restore the same value after postback. How to do

that?

2. Currently this part of my code appears almost at the end of the page where user has clicked vertical scroll bar to get into this section. After scrolling down if the clicks the hide/show link the data will be
displayed/hidden but the user will be shown the top of the page. Some

thing
like my smart navaigation is not effective. I know I am not posting the page
back when the user clicks on the hide/show link. But how to restore

the vertical postion of the form when the user clicks on hid/show button.

Your comments and suggestions are highly appreciated.

Benjamin
<%@ Page Language="vb" AutoEventWireup="false"

Codebehind="WebForm1.aspx.vb"
Inherits="HomeTestApp.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
<!--
function hideshow(obj)
{
if (document.getElementById(obj).style.display == "block")
document.getElementById(obj).style.display = "none";
else
document.getElementById(obj).style.display = "block";
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
border="1">
<tr>
<td><a href="#" onclick="hideshow('row5')">Hide Show</a><INPUT
type="hidden" id="hdnRowSts" value="none" name="hdnRowSts"></td>
</tr>
<tr id="row5" style="DISPLAY:none">
<TD>
<asp:Label id="Label1" runat="server">Label1</asp:Label></TD>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">Label2</asp:Label>
<asp:Button id="btnDoPostBack" runat="server"
Text="btnDoPostBack"></asp:Button></td>
</tr>
</TABLE>
</form>
</body>
</HTML>



Nov 19 '05 #5

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

Similar topics

12
by: Ryan Paul | last post by:
I've spent a lot of time using python, and personally, I feel like it is vastly superior when compared to languages like java, and c++, but there are still a few things that detract from its...
11
by: bearophile | last post by:
Hello, here are a four more questions (or suggestions) for the language (probably people have already discussed some of/all such things: I've seen the contracts for Python:...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
0
by: Peter R. Vermilye | last post by:
I am involved on a web application that is using a third party set of APIs for remote database access (middleware). I've been brought in because of my background in programming, thus I'm new to...
14
by: CMM | last post by:
Do the developers of Visual 2005 actuall use it??? There's lots of great things in VS2005 (mostly related to the outstanding work done on the CLR)... but in general the LITTLE THINGS totally drag...
35
by: Steven T. Hatton | last post by:
Perhaps I'm just a bit frustrated, and I will soon realize the clear truth of the matter, but right now I have some serious misgivings about the value of investing a lot of time and effort into...
75
by: Steven T. Hatton | last post by:
No, this is not a troll, and I am not promoting Java, C-flat, D, APL, Bash, Mathematica, SML, or LISP. A college teacher recently posted to this newsgroup regarding her observation that there has...
13
by: TSB | last post by:
Hi everyone, I think algorithm is very important for every computer language. But I don't know another important things. I am newbie to computer languages, so anyone can tell me what the most...
12
by: Michael Bell | last post by:
I am trying to put my learning effort into the most useful things. What do pointers do that other things can't? Michael Bell --
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
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.