Solved

Set target on ASP.NET button component.

Posted on 2010-09-16
4
695 Views
Last Modified: 2012-05-10
I have an ASP.NET Link button which I am using to redirect a user to another page. The link button is located within an IFRAME so I set the target to '_parent' in order for the redirect to affect the overall webpage. This all works fine, however the styling of the link button is causing an issue and it is preferred that the Link Button is replaced with a standard button. I have replaced the component and am using the PostBackUrl attribute to define the redirect path BUT the problem comes with making the ASP.NET button redirect the entire page and not just the iframe contents. Anyone know how I can cause a Button to redirect an entire page rather than just the iframe that contains it - in the same way as declaring the target attribute with a Link Button.
0
Comment
Question by:Blowfelt82
  • 3
4 Comments
 
LVL 2

Expert Comment

by:vsosu
ID: 33690873
Use OnClientClick attribute and use javascript with return false to reload page.
Example:
OnClientClick="redirectme();return false;"
0
 
LVL 2

Expert Comment

by:vsosu
ID: 33690905
use return false to avoid reload of current page.
0
 
LVL 2

Accepted Solution

by:
vsosu earned 500 total points
ID: 33690998

Code Snippet:

<script language="javascript">

    function redirectme() {

        var f = document.getElementById('frame1');

        f.src = "//www.microsoft.com";

    }

</script>



<iframe id="frame1" name="frame1" src="Default.aspx"  width="100px" height="100px"></iframe>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now