By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

How can I refresh a page?

P: n/a
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based authentication and think I know how to accomplish this part. My problem is that the top frame does not reload to get to the "If User.Identity.IsAuthenticated Then". Please don't tell me I shouldn't be using frames; this is a school assignment and the deadline is a week away (no time to redo what I have already done). Is there a way to get this link to change after the top.aspx page has already loaded?

Thank you for you help,
Judy
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Assuming that you are authorizing the user in a frame other than the top, but with the same parent. If this is the case you can reload the top frame with the following javascript code.

RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>parent.FRAMENAME.document.Fo rm1.submit()</" & "Script>")

Replace the FRAMENAME with the name of the top frame as it is in the Framesetting document. You can then put the code which checks if the user has already logged on in the page_load event of top.aspx as this is the only method that will be executed when the page reloads.

If you are authorizing the user in a pop up, say from the Login link in the top frame, the javascript code will be a little different.

RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>window.opener.document.Form1 .submit()</" & "Script>")

window.opener will reference the window that has opened the pop-up page. Put the code in the page_load as just described and you should not have a problem.

hope this solves your problem,
John

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based authentication and think I know how to accomplish this part. My problem is that the top frame does not reload to get to the "If User.Identity.IsAuthenticated Then". Please don't tell me I shouldn't be using frames; this is a school assignment and the deadline is a week away (no time to redo what I have already done). Is there a way to get this link to change after the top.aspx page has already loaded?

Thank you for you help,
Judy

Nov 18 '05 #2

P: n/a
Hi Judy,

You can emit some client-side JavaScript in your main frame that tells the
top.aspx to refresh. At that time it will find out that the user is
authenticated and can show the correct hyperlink. Here's an article about
using refresh:

http://developer.irt.org/script/591.htm

In your main page, use the Page.RegisterClientScriptBlock Method to emit the
client-side script:

http://msdn.microsoft.com/library/de...BlockTopic.asp

Ken
Microsoft MVP [ASP.NET]
"Judy Ward" <Ju******@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
I have an index.aspx with frames. The top frame has a navigation bar with
a "Login" hyperlink. If the user has already logged in I want this link to
change to "Logout". I am using forms-based authentication and think I know
how to accomplish this part. My problem is that the top frame does not
reload to get to the "If User.Identity.IsAuthenticated Then". Please don't
tell me I shouldn't be using frames; this is a school assignment and the
deadline is a week away (no time to redo what I have already done). Is
there a way to get this link to change after the top.aspx page has already
loaded?

Thank you for you help,
Judy


Nov 18 '05 #3

P: n/a
A standard html hyperlink will not cause the page to post back to the server. Instead of using a html hyperlink, use a LinkButton asp.net web control and set its autopostback to true. This way when the user clicks the Linkbutton it will look like a hyperlink but will act like a submit button. Put your conditional code in the Page_Load. More info is needed if this does not solve you issue.

You may also want to turn off any page caching so your login could dispaly logout immediately without a delay. This may not be already an issue

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based authentication and think I know how to accomplish this part. My problem is that the top frame does not reload to get to the "If User.Identity.IsAuthenticated Then". Please don't tell me I shouldn't be using frames; this is a school assignment and the deadline is a week away (no time to redo what I have already done). Is there a way to get this link to change after the top.aspx page has already loaded?

Thank you for you help,
Judy

Nov 18 '05 #4

P: n/a
When I look at the asp LinkButton I don't see an autopostback property (and I get the red wavy line if I type it in anyway). Is it called something else?

Also, with an asp hyperlink I have a NavigateUrl and Target property. I can't figure out how to make the link button launch my login.aspx page in "main". Can you give me an example of using the LinkButton to do this?

Thank you for your response!
Judy

"Tampa .NET Koder" wrote:
A standard html hyperlink will not cause the page to post back to the server. Instead of using a html hyperlink, use a LinkButton asp.net web control and set its autopostback to true. This way when the user clicks the Linkbutton it will look like a hyperlink but will act like a submit button. Put your conditional code in the Page_Load. More info is needed if this does not solve you issue.

You may also want to turn off any page caching so your login could dispaly logout immediately without a delay. This may not be already an issue

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based authentication and think I know how to accomplish this part. My problem is that the top frame does not reload to get to the "If User.Identity.IsAuthenticated Then". Please don't tell me I shouldn't be using frames; this is a school assignment and the deadline is a week away (no time to redo what I have already done). Is there a way to get this link to change after the top.aspx page has already loaded?

Thank you for you help,
Judy

Nov 18 '05 #5

P: n/a
I am authorizing the user from the "main" frame in my Login.aspx page. I would love to use the code you described below to refresh my "top" frame, but I can't figure out where to put it. I put it in the btnLogin_Click method in Login.aspx.vb, and nothing happened. I am not familiar with javascript, I have only been using vb with asp.net. Any more suggestions would be appreciated.

Thank you,
Judy

"John Sivilla" wrote:
Assuming that you are authorizing the user in a frame other than the top, but with the same parent. If this is the case you can reload the top frame with the following javascript code.

RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>parent.FRAMENAME.document.Fo rm1.submit()</" & "Script>")

Replace the FRAMENAME with the name of the top frame as it is in the Framesetting document. You can then put the code which checks if the user has already logged on in the page_load event of top.aspx as this is the only method that will be executed when the page reloads.

If you are authorizing the user in a pop up, say from the Login link in the top frame, the javascript code will be a little different.

RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>window.opener.document.Form1 .submit()</" & "Script>")

window.opener will reference the window that has opened the pop-up page. Put the code in the page_load as just described and you should not have a problem.

hope this solves your problem,
John

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based authentication and think I know how to accomplish this part. My problem is that the top frame does not reload to get to the "If User.Identity.IsAuthenticated Then". Please don't tell me I shouldn't be using frames; this is a school assignment and the deadline is a week away (no time to redo what I have already done). Is there a way to get this link to change after the top.aspx page has already loaded?

Thank you for you help,
Judy

Nov 18 '05 #6

P: n/a
Hi Judy,

I believe you have the code in the correct place. If it is not working you can check if the name of the Frame (FRAMENAME) in my code, matches the name of the Frame as it is in the Name tag in the Framesetting document. Also for this code to work the main frame where you are executing the code has to be a sister of the login frame, meaning that they need to have the same parent. Ex.

<frameset>
<frame name="top" src="top.aspx">
<frame name="main" src="main.aspx">
</frameset>

It should look something like this. In this case you have to replace FRAMENAME with 'top'.

Also another thing is that the form name should be Form1, which is the default.

If this does not work, try right clicking on your main page after it is rendered and selecting view source. You should see the javascript code somewhere, if it is not there something else is wrong.

hope this helps,
John

"Judy Ward" wrote:
I am authorizing the user from the "main" frame in my Login.aspx page. I would love to use the code you described below to refresh my "top" frame, but I can't figure out where to put it. I put it in the btnLogin_Click method in Login.aspx.vb, and nothing happened. I am not familiar with javascript, I have only been using vb with asp.net. Any more suggestions would be appreciated.

Thank you,
Judy

"John Sivilla" wrote:
Assuming that you are authorizing the user in a frame other than the top, but with the same parent. If this is the case you can reload the top frame with the following javascript code.

RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>parent.FRAMENAME.document.Fo rm1.submit()</" & "Script>")

Replace the FRAMENAME with the name of the top frame as it is in the Framesetting document. You can then put the code which checks if the user has already logged on in the page_load event of top.aspx as this is the only method that will be executed when the page reloads.

If you are authorizing the user in a pop up, say from the Login link in the top frame, the javascript code will be a little different.

RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>window.opener.document.Form1 .submit()</" & "Script>")

window.opener will reference the window that has opened the pop-up page. Put the code in the page_load as just described and you should not have a problem.

hope this solves your problem,
John

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based authentication and think I know how to accomplish this part. My problem is that the top frame does not reload to get to the "If User.Identity.IsAuthenticated Then". Please don't tell me I shouldn't be using frames; this is a school assignment and the deadline is a week away (no time to redo what I have already done). Is there a way to get this link to change after the top.aspx page has already loaded?

Thank you for you help,
Judy

Nov 18 '05 #7

P: n/a
John,

I've one question extended from this thread.

I've two frames in default.aspx
<iframe name="menu" runat="server"/>
<iframe name="main" runat="server"/>

login process is in Main frame, when use press the Button "Login", and
the authentication is ok, I want Menu frame refresh, the same time when Main
frame refresh or redirect.

How can I achieve this ?
Assuming that you are authorizing the user in a frame other than the top, but with the same parent. If this is the case you can reload the top frame
with the following javascript code.
RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>parent.FRAMENAME.document.Fo rm1.submit()</" &
"Script>")
Replace the FRAMENAME with the name of the top frame as it is in the Framesetting document. You can then put the code which checks if the user
has already logged on in the page_load event of top.aspx as this is the only
method that will be executed when the page reloads.
If you are authorizing the user in a pop up, say from the Login link in the top frame, the javascript code will be a little different.
RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>window.opener.document.Form1 .submit()</" & "Script>")
window.opener will reference the window that has opened the pop-up page. Put the code in the page_load as just described and you should not have a
problem.
hope this solves your problem,
John

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this
link to change to "Logout". I am using forms-based authentication and think
I know how to accomplish this part. My problem is that the top frame does
not reload to get to the "If User.Identity.IsAuthenticated Then". Please
don't tell me I shouldn't be using frames; this is a school assignment and
the deadline is a week away (no time to redo what I have already done). Is
there a way to get this link to change after the top.aspx page has already
loaded?
Thank you for you help,
Judy

Nov 18 '05 #8

P: n/a
Hi Edward,

The RegisterStartupScrict code below should work if you place it right after the login process. When the main frame is refreshed it will render the script and refresh the menu frame.

It will not work if you redirect the page though. If the page is redirected, the Register scripts will not render on the redirected page, and thus the menu frame will not refresh.

In order to achieve this with a redirect you would have to either do one of the following:

1 - Redirect using javascript using document.location.href=NEWPAGENAME (Add this to the startupscript.

or

2 - Insert the RegisterStartupScript code in the redirected page, possibily using a querystring to flag it to do so.

hope this helps you,
John

"Edward" wrote:
John,

I've one question extended from this thread.

I've two frames in default.aspx
<iframe name="menu" runat="server"/>
<iframe name="main" runat="server"/>

login process is in Main frame, when use press the Button "Login", and
the authentication is ok, I want Menu frame refresh, the same time when Main
frame refresh or redirect.

How can I achieve this ?
Assuming that you are authorizing the user in a frame other than the top,

but with the same parent. If this is the case you can reload the top frame
with the following javascript code.

RegisterStartupScript("Reload", "<SCRIPT

Language='Javascript'>parent.FRAMENAME.document.Fo rm1.submit()</" &
"Script>")

Replace the FRAMENAME with the name of the top frame as it is in the

Framesetting document. You can then put the code which checks if the user
has already logged on in the page_load event of top.aspx as this is the only
method that will be executed when the page reloads.

If you are authorizing the user in a pop up, say from the Login link in

the top frame, the javascript code will be a little different.

RegisterStartupScript("Reload", "<SCRIPT

Language='Javascript'>window.opener.document.Form1 .submit()</" & "Script>")

window.opener will reference the window that has opened the pop-up page.

Put the code in the page_load as just described and you should not have a
problem.

hope this solves your problem,
John

"Judy Ward" wrote:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this
link to change to "Logout". I am using forms-based authentication and think
I know how to accomplish this part. My problem is that the top frame does
not reload to get to the "If User.Identity.IsAuthenticated Then". Please
don't tell me I shouldn't be using frames; this is a school assignment and
the deadline is a week away (no time to redo what I have already done). Is
there a way to get this link to change after the top.aspx page has already
loaded?
Thank you for you help,
Judy


Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.