ASP.NET frameset target to new frame
I have an ASP.NET page in a frameset. I divided into 2 frames, 1.LEFTNAVI and 2.MAIN.
In the first frame (LEFTNAVI) I'm using a textbox and a button for the search engine in below tree menu. If I click the search button or menu it will display the result in the 2nd frame (MAIN) (that is, target=MAIN
). Now the problem is, the application session ends, then I click the search button. It will display the login page to start the session, after login, it is displaying the LEFTNAVI frame text in MAIN frame. That is, the textbox, search button and tree menu is displayed in MAIN frame.
Below is the code I'm using in left.aspx
.
<script type="text开发者_如何学C/javascript" language="javascript">
function pageSubmit()
{
var myForm = document.getElementById('form1');
myForm.target = 'main';
}
function KeyDownHandler(btn)
{
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
</script>
<body>
<form id="form1" method="post" runat="server">
<div id="searchFunc" runat="server">
<asp:TextBox
ID="txtSearch"
CssClass="txtbox"
onKeyDown= "KeyDownHandler(searchButt)"
runat="server"></asp:TextBox>
<asp:Button
ID="searchButt"
runat="server"
CssClass="smallbutton"
Text="Search"
onclick="searchButt_Click"
OnClientClick="pageSubmit()" />
</div>
<br />
<br />
<asp:TreeView
CssClass="treeview"
ID="tree"
runat="server"
LineImagesFolder="~/TreeLineImages"
ShowLines="True" ExpandDepth="1" >
<Nodes>
<asp:TreeNode Text="sample tree menu" Value="sam" SelectAction="Expand">
</Nodes>
</asp:TreeView>
</form>
</body>
You can use redirect url. in this case your login page should have a parameter in query string witch will demonstrate the page url that redirected to login page and sure login page should redirect to that page after successful login.
in this case login page should check for redirect url after successful login and automatically redirect to it. in your case, it will redirect to result page (not search page).
sample scenario :
private void DoLogin()
{
//write some code for user validation
if(loggedin) //login was successful
{
//redirect to page that redirected to login because of session end
var redirectUrl = Request.QueryString["redirectUrl"];
Response.Redirect(redirectUrl);
}
}
remember if you are using membership provider of asp.net it will do it for your.
精彩评论