Wondering if any one has a good example for the issue below:
I have a table which displays sql results. Within each row i have an image hyperlink which allows me to open a hidden row directly below the record using a querystring.
In this row is a simple form which posts a value back to the page.
What i am having issues with is the ability to maintain the possition of the page after postback. By using a simple <a name="unique_name"> in the row i can get a blocky navigation to the row but as with <a> names it display the row at the top of the page.
Below is a mockup of the table with both the record row and hidden row:
Code:
<%
'Query Strings
QsRowID = Request.QueryString("rid")
%>
<%
'Retrieve form value
SelVal=Request.Form("SelVal")
%>
<html>
<head>
</head>
<body>
<div align="center">
<table width="600" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="600" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<%
'clear row id
RowID=""
'Create records loop
for a = 0 to 45
'Create Unique row id for example
If RowID = "" then
RowID = 1
else
RowID = RowID + 1
End If
%>
<tr>
<td width="600" height="40" valign="middle">Record Row! <a href="example.asp?rid=<%=RowID%>"> Display hidden row below - <%=RowID%></a></td>
</tr>
<%
'Show Hidden row
If Trim(RowID) = Trim(QsRowID) then
%>
<form name="form" method="post" action="example.asp?rid=<%=RowID%>">
<tr>
<td height="40" valign="middle">
Hidden Row
<select name="SelVal">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="submit" name="submit" value="submit">
<%
If Len(SelVal)>0 then
Response.Write "You selected " & SelVal
End If
%>
</td>
</tr>
</form>
<%
End If
%>
<%Next%>
</table></td>
</tr>
<tr>
<td height="560"> </td>
</tr>
</table>
</div>
</body>
</html>
I have been looking at various javascript examples but have not got any to work as yet.
Below is an example of page location that i have not been able to adapt:
http://forums.asp.net/t/336101.aspx
Put before end your form (before </form> tag):
<input id="__SAVESCROLL" name="__SAVESCROLL" value="0" type="hidden" runat="server" />
<script type="text/javascript" src="SaveScroll.
js"></script>
To the SaveScroll.
js file put:
function saveScroll()
{
var sScroll;
if (document.documentElement && document.documentElement.scrollTop)
sScroll = document.documentElement.scrollTop;
else if (document.body)
sScroll = document.body.scrollTop;
else
{
sScroll = 0;
}
document.getElementById('__SAVESCROLL').value = sScroll;
}
function restoreScroll()
{
var sScroll = document.getElementById('__SAVESCROLL').value;
if (sScroll > 0)
{
if (document.documentElement && document.documentElement.scrollTop)
document.documentElement.scrollTop = sScroll;
else if (document.body)
{
if (window.navigator.appName == 'Netscape')
window.scroll(0, sScroll);
else
document.body.scrollTop = sScroll;
}
else
{
window.scroll(0, sScroll);
}
// here is setting absolute positioning panel, if you need, set correct ID and uncomment follow 2 lines (and add needed lines/setting for all your panels)
//if (document.getElementById('pnlNewItem') != null )
//document.getElementById('pnlNewItem').style.top = sScroll + 'px';
}
}
window.onload = restoreScroll;
window.onscroll = saveScroll;
window.onresize = saveScroll;
To the head section of page put this conditionally comment meta-tag for quick page transition(in IE6+ will create very smooth postback, in other will be ignored because they dont support transition or dont support 0.1 time to play transition)
<!--[if gte IE 6]><meta http-equiv="Page-Enter" content="BlendTrans(Duration=0.1)" /><![endif]-->
If anyone can point me in the right direction that would be superb.
Cheers
Aspless