• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Redirect in the same window

I’m trying after i click the button to be Redirect in the same window or page or  I want the first page witch is the login page to be closed regarding the code below because I’m not familiar with javascript...


Private Sub Button1_Click(ByVal sender As Object,ByVal e As EventArgs Handles Button1.Click
     If String.Compare(user.text,"a",True) = 0 Then
          Dim builder As New System.Text.StringBuilder()
          builder.AppendFormat("<script language='javascript'>window.open('{0}','{1}','{2}');</script>", _
               "popupwindow.aspx", _
               string.Empty, _
               "width=400,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no")
          Page.RegisterStartupScript("popup", builder.ToString())
     End If
End Sub
0
bduhaish
Asked:
bduhaish
  • 3
  • 2
1 Solution
 
b1xml2Commented:
you cant close the parent window without user intervention.

the syntax to close any window is self.close();

but the point is only windows which have been open programatically can be closed programmatically. This is a security implementation by design.
0
 
Hamed ZaghaghiCommented:
you can simply close the parent window with opener.close() in the popupwindow.aspx.

have a good programming day;
--hamed
0
 
bduhaishAuthor Commented:
ok about closing the parent window is clear , but is there a way to open in the same target like target="_self"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
b1xml2Commented:
yep,

Private Sub Button1_Click(ByVal sender As Object,ByVal e As EventArgs Handles Button1.Click
     If String.Compare(user.text,"a",True) = 0 Then
          Dim builder As New System.Text.StringBuilder()
          builder.AppendFormat("<script language='javascript'>window.open('{0}','{1}','{2}');</script>", _
               "popupwindow.aspx", _
              "_self", _
               "width=400,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no")
          Page.RegisterStartupScript("popup", builder.ToString())
     End If
End Sub
0
 
b1xml2Commented:
you wont be able to change the features of the parent window. like hiding the toolbar etc.

because of this, it is pointless in doing this, it is better to use Response.Redirect
0
 
bduhaishAuthor Commented:
hamed

thanks..........

b1xml2
like you said i will not be able to change the features of the parent window,so i'll go back to the default a way

thanks..........
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now