Opening page in the parent window using LinkButton

I was using frames one was 20% and the other was 80% (Rows) and the smaller frame had a linkbutton which was used to log out the user. I implemented the code as
 
private void LinkButton1_Click(object sender, System.EventArgs e)
		{
			
			// Log out the user here 
            			
			// redirect to the login page		
			string path = "http://localhost/Default.aspx"; 
			Response.Redirect(path);

						
		}

Unfortunately the Default.aspx page always appear in the 20% frame window. And I wanted it to appear as a whole page. You can easily fix this by attaching client side javascript to the code. Add the following code in the InitializeComponent of the page.
 

this.LinkButton1.Attributes.Add("onclick","Form1.target='_parent';"); 

Update: If you are using linkbutton inside a usercontrol then use the FormID of the page which contains the userControl.

Print | posted @ Tuesday, September 13, 2005 12:15 PM

Twitter