Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu page javascript redirect problems 1

Status
Not open for further replies.

Zarcom

Programmer
May 7, 2002
1,275
CA
Hey guys

Some Background
I had a simple html page the redirected the main frame to the page that was click on. My menu however got too big and I changed it to an aspx page.
1. To have rollup and dropdown menu's
2. So that one of the links could send a query string built from session variables.

Problem
One button (the report one) calls a function that servers dual purposes. It redirects the main page and the menu page (itself). However because (or so i believe) it is an aspx page and refreshes itself the menu is not redirected.

I am not sure how to go about fixing this. Any ideas to put me on track are appreciated.

The problem code looks like so.

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>SiteManagerMenu</title>
<LINK href=&quot;CSS/Sitemanager.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;>
<SCRIPT language=&quot;javascript&quot; id=&quot;clientEventHandlersJS&quot;>
<!--
function cmdReports_onclick() {
document.menudirect.action=&quot;ReportsMenu.htm&quot;;
document.redirect.action=&quot;SiteManagerMain.htm&quot;;
document.redirect.submit();
document.menudirect.submit();
}
//-->
</SCRIPT>
</HEAD>
<body MS_POSITIONING=&quot;FlowLayout&quot;>
<form name=&quot;Form1&quot; method=&quot;post&quot; action=&quot;SiteManagerMenu.aspx&quot; id=&quot;Form1&quot;>
<input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; value=&quot;blah blah&quot; />

<input type=&quot;image&quot; name=&quot;cmdReports&quot; id=&quot;cmdReports&quot; onclick=&quot;javascript: return cmdReports_onclick();&quot;src=&quot;/RoamingForest/Pix/Reports.gif&quot; border=&quot;0&quot; />
<P></P>
</form>
<form id=&quot;redirect&quot; name=&quot;redirect&quot; action=&quot;ModifySite.asp&quot; target=&quot;main&quot;>
<INPUT id=&quot;self&quot; style=&quot;VISIBILITY: hidden&quot; type=&quot;text&quot; value=&quot;sitemanager&quot; name=&quot;self&quot;>
</form>
<form id=&quot;menudirect&quot; name=&quot;menudirect&quot; target=&quot;_self&quot;>
</form>
</body>
</HTML>
That'l do donkey, that'l do
[bravo] Mark
 
Ok, let's say I had a button that I wanted to do the following when clicked:

(1)Move the current page to 1.aspx
(2)Move the other page (frame 2) to 2.aspx

I'll assume that there are two frames in the frameset, and the menu page is frames[0] (the first frame).

I might do it like this:

<asp:button id=btnAction text=&quot;Click Me&quot; runat=server />
<asp:label id=lblScript runat=server />
~~~~~~~~~~~~
protected sub redirect(signature...) handles btnAction.click
dim sb as new stringBuilder()
sb.append(&quot;<script language=javascript>&quot;)
sb.append(&quot;parent.top.frames[1].location = '2.aspx';&quot;)
sb.append(&quot;location = '1.aspx';&quot;)
sb.append(&quot;</script>&quot;)
lblScript.text = sb.toString()
end sub

So we just write out the client side script to do our bidding.... would be pretty easy to modify this example to fit nearly any need, as well (such as closing a window after action in a popup, for instance -- which is what I use this for alot).

Hope that helps! :)
paul
penny1.gif
penny1.gif
 
ahh Paul the godfather of the ASP.NET forum. Thanks a bunch that worked perfect. That'l do donkey, that'l do
[bravo] Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top