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>